Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subtract from datetime (C) 1

Status
Not open for further replies.

foxup

Programmer
Dec 14, 2010
328
CA
Hi,

I have a (C) character field that has the following value in it:

"31/12/2014 2:43:39 PM" (without the quotes)


I would like to subtract 5 hours from that. can somebody help me please. I'm sure it's something simple but my brain is in 'frozen' mode due to the weather here.


Thanks in advance,
FOXUP!
 
lcTime = '31/12/2014 2:43:39 PM'

? CTOT(lcTime) - 5*3600


Ez Logic
Michigan
 
^ Assuming you have SET DATE BRITISH



Ez Logic
Michigan
 
You better store datetime values in datetime fields. Then CTOT will not be needed and there is no dependency on date settings.

Bye, Olaf.
 
Thanks ezlogic. works great! :)

hi Olaf. I will definitely consider doing that. :)

thanks to all.
FOXUP
 
And I'm with Olaf and EZ on that.

Further benefit: if it's stored as Datetime, you don't have to account for SET DATE.

5 hours before a datetime is 5 hours no matter how you'v SET DATE.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top