I want to subtract 18 hours from the current date… Is there a function that can subtract hours from the currentdate() function?
I tried relativedate() function but it can only do days…
thanks!
outatime (BOB member since 2007-11-20)
I want to subtract 18 hours from the current date… Is there a function that can subtract hours from the currentdate() function?
I tried relativedate() function but it can only do days…
thanks!
outatime (BOB member since 2007-11-20)
aniketp (BOB member since 2007-10-05)
Moderator note:
Aniket,
Please do not provide a “solution” where an OP is forwarded to another site where a solution is available only to premium members, i.e. is not free and needs to be paid for. This goes against the nature of this board.
Thanks for understanding.
Marek Chladny (BOB member since 2003-11-27)
Hi Marek,
Thanks for letting me know and sorry I was not aware that it is paid site.
I saw the solution that’s why I shared, I don’t know what went wrong but sure from next time onwards I will take care of this…
DATEADD('n',18,DATETIMEFIELD)
aniketp (BOB member since 2007-10-05)
That’s correct.
Try having a look at this old post in the DeskI forum. The formula posted there should get you started: Changing the time portion of timestamp
The final formula is not very clean and elegant so I suggest doing the calculation on the universe/SQL level, like Aniket suggested in his post above.
Marek Chladny (BOB member since 2003-11-27)
I need to do it in the Webi layer because the custom sql access is disabled by the BO admins…
I’m trying to understand the code you have in Deski. Which part here should I insert the subtraction of 18 hours?
=ToDate(FormatDate(RelativeDate(ToDate(FormatDate(<date variable> ,"dd-mm-yyyy") ,"dd-mm-yyyy") ,Floor((ToNumber(FormatDate(<date variable> ,"HH"))*3600 + ToNumber(Right(FormatDate(<date variable> ,"HHmm") ,2))*60 + ToNumber(FormatDate(<date variable> ,"ss")) + 3600)/86400)) ,"dd-mm-yyyy") & " " & FormatNumber(Floor((ToNumber(FormatDate(<date variable> ,"HH"))*3600 + ToNumber(Right(FormatDate(<date variable> ,"HHmm") ,2))*60 + ToNumber(FormatDate(<date variable> ,"ss")) + 3600)/3600) ,"00") & ":" & FormatNumber(Floor(Mod((ToNumber(FormatDate(<date variable> ,"HH"))*3600 + ToNumber(Right(FormatDate(<date variable> ,"HHmm") ,2))*60 + ToNumber(FormatDate(<date variable> ,"ss")) + 3600) ,3600)/60) ,"00") & ":" & FormatNumber(Mod(Mod((ToNumber(FormatDate(<date variable> ,"HH"))*3600 + ToNumber(Right(FormatDate(<date variable> ,"HHmm") ,2))*60 + ToNumber(FormatDate(<date variable> ,"ss")) + 3600) ,3600) ,60) ,"00") , "dd-mm-yyyy HH:mm:ss")
outatime (BOB member since 2007-11-20)
Hi,
If I remember correctly (it’ been more than 5 years since I wrote that formula), the formula adds 1 hour to the date specified in . So all occurrences of “+ 3600” in the formula is about adding that many seconds, it means 1 hour to the given date.
So try changing all 4 occurrences of “+ 3600” to “- 64800”, which means subtracting of 64800 seconds, it means 18 hours.
Marek Chladny (BOB member since 2003-11-27)
Hi All,
just checked, RelativeDate works with fractions, so to add 18 hours just do [finaldate] = RelativeDate([your date];0.75
Cheers,
Rogerio
rgoulart (BOB member since 2011-08-21)
just checked, RelativeDate works with fractions, so to add 18 hours just do [finaldate] = RelativeDate([your date];0.75
That’s correct as well
But it hasn’t been like this in all BOBJ versions. I think BO BI 4 introduced this enhancement to the RelativeDate() function.
Marek Chladny (BOB member since 2003-11-27)
just checked, RelativeDate works with fractions, so to add 18 hours just do [finaldate] = RelativeDate([your date];0.75
whoah! I never thought of doing that! you’re smart!
So try changing all 4 occurrences of “+ 3600” to “- 64800”, which means subtracting of 64800 seconds, it means 18 hours.
thanks this will be useful for older BO versions!
outatime (BOB member since 2007-11-20)
It wasn´t my idea, I took it from
Hi
I just wanted to add an hour with my existing timestamp, your input is more appreciated. I wanted to do this only on the Report and not on the universe.
Say the time in the column 14-08-2009 14:30:00, i wanted to display it as 14-08-2009 15:30:00
Regards
Siva.M
looksmee
(BOB member since 2006-02-08)
Cheers,
Rogerio
rgoulart (BOB member since 2011-08-21)