Converting sql data from datetime to string

Post Reply
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Converting sql data from datetime to string

Post by Marco Turco »

Hi all,
I'm reading an sql db with a datetime field using fwh+xharbour ADO.
The variable I got for this field is a "T" type format, how can I convert it to a string for further manipulations ?

Thank you in advance.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Converting sql data from datetime to string

Post by Rick Lipkin »

Marco

Here is a function that was given to me and takes Date\Time ValType "T" to ValType "D"

Rick Lipkin

Code: Select all

Function TtoDate( tDate )

If empty( tDate)
   Return( ctod("00/00/00"))
Endif

If ValType( tDate ) = "D"
   Return(tDate )
Endif

Return( stod( substr( ttos( tDate ), 1, 8 ) ))
 
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Converting sql data from datetime to string

Post by nageswaragunupudi »

The variable I got for this field is a "T" type format, how can I convert it to a string for further manipulations ?
You can do all kinds of manipulations by retaining the value as type "T" ( DateTime type). There is more flexibility with "T" type data than broken down parts of Date and Time separately.
If you explain what kind of manipulations you want to do, I shall provide my suggestions.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Converting sql data from datetime to string

Post by Marco Turco »

Hi, thank you for your reply.
I only need to extract the data and time components and put them in two char variables.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Converting sql data from datetime to string

Post by nageswaragunupudi »

Date as Character:

DTOC( tDateTimeValue )

Time as character:

LEFT( AFTERATNUM( " ", TTOC( tDateTimeVal ) ), 5 )
Regards

G. N. Rao.
Hyderabad, India
Post Reply