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.
Converting sql data from datetime to string
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Converting sql data from datetime to string
Best Regards,
Marco Turco
SOFTWARE XP LLP
Marco Turco
SOFTWARE XP LLP
- 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
Marco
Here is a function that was given to me and takes Date\Time ValType "T" to ValType "D"
Rick Lipkin
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 ) ))
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Converting sql data from datetime to string
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.The variable I got for this field is a "T" type format, how can I convert it to a string for further manipulations ?
If you explain what kind of manipulations you want to do, I shall provide my suggestions.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Re: Converting sql data from datetime to string
Hi, thank you for your reply.
I only need to extract the data and time components and put them in two char variables.
I only need to extract the data and time components and put them in two char variables.
Best Regards,
Marco Turco
SOFTWARE XP LLP
Marco Turco
SOFTWARE XP LLP
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Converting sql data from datetime to string
Date as Character:
DTOC( tDateTimeValue )
Time as character:
LEFT( AFTERATNUM( " ", TTOC( tDateTimeVal ) ), 5 )
DTOC( tDateTimeValue )
Time as character:
LEFT( AFTERATNUM( " ", TTOC( tDateTimeVal ) ), 5 )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India