I have a table (which i cannot modify) where date and time fields are stored as VARCHAR. But i have to cast these fields into timestamp.
My requirement is like,
timestamp (select date, time where max(timestamp(d ate,time));
How to do this in postgres?
3 14905 michaelb 534
Recognized Expert Contributor
I'm not sure if you can really cast varchar into timestamp, (although I don't have the latest version of Postgres, which may have a larger set of cast operators), but you can try something like this instead: - select (mydate || ' ' || mytime) from foo where (mydate || ' ' || mytime) = (select max (mydate || ' ' || mytime) from foo);
Thank you,
I found a function to_timestamp and it casts string into timestamp
I tried sth like ,
to_timestamp('0 1 Jan 2007 09:09:09', 'DD Mon YYYY HH:MI:SS')
It works .
michaelb 534
Recognized Expert Contributor
Great, thanks for letting me know. michael Sign in to post your reply or Sign up for a free account.
Similar topics |
by: George Develekos |
last post by:
I need to import into mysql data from DB2. One of the DB2 table columns
is of the TIMESTAMP type, which, unlike its MySQL counterpart, supports
fractions of a second, up to 6 digits, i.e. it is of the form
2005-07-13-23:45:32.000000
....whereas the MySQL timestamp type is of the form
2005-07-13 23:45:32
|
by: Jitender Kumar C |
last post by:
Hi,
I want to extract date part (mm/dd/yy or any other date format) of Timestamp in postgreSQL. Can anyone help me out how I can proceed?.
Regards,
Ch.V.J. Kumar
|Associate Consultant | iGATE Global Solutions Limited | Office: 5521701 xtn 3031 | 9886219429| Jitender.Chakka@igate.com
|
by: Campano, Troy |
last post by:
Hi,
I'm trying to compare a timestamp to current_timestamp but I'm having
trouble.
I want to compare just the date piece of my timestamp column to just the
date piece of current_timestamp.
I'm getting weird results that I don't understand.
When I use TO_DATE it changes the year, month, etc.
Any ideas?
|
by: Jim C. Nasby |
last post by:
Is there any reason why there isn't a predefined cast to go from a
timestamp to a varchar? Is there a reason not to add one?
--
Jim C. Nasby, Database Consultant jim@nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or...
|
by: T.M. |
last post by:
What is the correct syntax for querying the first 20 characters of a
memo field?
I'm trying to
SELECT CAST (varchar(20) fieldname) as newfieldname
and i get a bunch of errors
Can someone please help me?
MS Access DB used with ColdFusion
| |
by: T.M. |
last post by:
What is the correct syntax for querying the first 20 characters of a
memo field?
I'm trying to
SELECT CAST (varchar(20) fieldname) as newfieldname
and i get a bunch of errors
Can someone please help me?
MS Access DB used with ColdFusion
|
by: whitsey |
last post by:
Hi,
I can easily convert a TIMESTAMP to a DATE which will give me results
in the format 'DD/MM/YYYY' however, what I want to do is convert the
TIMESTAMP to just 'MM/YYYY' or even better 'MMM/YYYY'.
I tried using the cast function as follows but it failed.
CAST(CURRENT TIMESTAMP AS DATE FORMAT 'mm/yy')
|
by: robykeys82 |
last post by:
Hi! I'm an Italian user of PostGres and I'm having some trouble! I hope you can help me!
I'm trying to migrate the db content from SQL SERVER 2005 to PostGreSQL. Everything works ok except for the "image" fields. I have this code:
PGComm.CommandText = "INSERT INTO "table name"(p1 p2 p3 p4 p5....)"
+ "VALUES(:p1 , :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13);";
.....................................
|
by: BusterKarmul |
last post by:
Hello,
Is it possible to determine the Min and Max timestamp intervals for records as they are inserted (SQL Server 2005)? The table accepts inserts only (no updates) and produces this output:
1 X1866246100 i22222 2011-03-07 05:59:37.863
2 X1884627200 K33333 2011-03-07 06:03:35.740
3 X1878488900 d44444 2011-03-07 06:04:10.520
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |