0

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

Rahul G
  • 1
  • 1
  • 1

2 Answers2

1

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

System.DateTime newDate
newDate =  System.DateTime.Now.AddMinutes(-1);
JJ_Coder4Hire
  • 4,706
  • 1
  • 37
  • 25
0

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)

Roland Smith
  • 957
  • 4
  • 7
  • Hai , Thank You for your reply.It is working but if the date is 22-sep-2014 00:00:00. – Rahul G Sep 22 '14 at 11:02
  • You can use the DateAdd SQL function in an inline statement. It will be less code and won't have the midnight issue. – Roland Smith Sep 22 '14 at 12:16
  • If you need to do this a lot you could create a SQL function with the datepart as a parameter and then use it to subtract whatever you need to from a date. – Matt Balent Sep 22 '14 at 22:42