Business Scenario.
So I came across this business scenario which was quite a challenge for me . It dealt with the all so gruesome Date/Time fields. The requirement was to display the GMT time from the local time of the server. The location of the server was Southern california i.e; PST. And GMT time is 8 hours ahead of PST. As most developers , this seemed to me as a simple sql query of adding 8 hours to the current date/time . I was surprised to find out that the basic sql function of TimestampADD was not supported under workflow conditions. After putting much thoughts and thanks to the bits and pieces of info in OTN forums , I figured out a way to add hours to current time stamp using the following.
The logic used was to conver the date/time field value in to string and extracting date and time from it using the Mid function and then hours as numeric to each extracted value. here's The syntax.
Mid(Timestamp()+(8.0/24.0),1,2)+'/'+Mid(Timestamp()+(8.0/24.0),4,2)+'/'+Mid(Timestamp()+(8.0/24.0),7,4)+' '+Mid(Timestamp()+(8.0/24.0),12,8)
The Timestamp() gets the current timestamp at the local server. The (8.0/24.0) adds the hours (ofcourse you can use some brains and convert the fraction to minutes). The remaining parameters states the position of the date value and the time value.
If only the following syntax is used
Mid(Timestamp(),1,2)+'/'+Mid(Timestamp(),4,2)+'/'+Mid(Timestamp(),7,4)+' '+Mid(Timestamp(),12,8)
then it displays the current date/time. You can use the above syntaxes both at the workflow level and field validation level.
Feel free to ask more.
Cheers!