subtract one minute from datetime in powerbuilder

4.4k Views Asked by At

I have seen a lot of info on how to subtract one datetime from the other and how to add years on to a datetime. but the following is giving me a headache. How to subtract 1 minute from date in powerbuilder?please help and support.

Thanks & Regards Rahul G

2

There are 2 best solutions below

3
On

This is how it is done in PowerScript. It would be easier if you did it in SQL using the DateAdd function.

DateTime ldt_thedate, ldt_newdate
Time lt_thetime

// get the current date-time
ldt_thedate = DateTime(Today(), Now())

// subtract 1 minute
lt_thetime = RelativeTime(Time(ldt_thedate), -1)

// assemble the date-time
ldt_newdate = DateTime(Date(ldt_thedate), lt_thetime)

0
On

if you are using powerbuilder.net you can do it in 2 line of code:

System.DateTime newDate
newDate =  System.DateTime.Now.AddMinutes(-1);