Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
7 replies
Subscribers
8 subscribers
Views
5274 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi. I am displaying the date time field on UI which is defaulted to previous day
jaishankarj
over 9 years ago
Hi. I am displaying the date time field on UI which is defaulted to previous day 00:00. But due to BST change my date time is getting displayed 1 hour ahead 01:00. I can wrap my datetime in gmt() function and get the desired result but this will force me to change it again when BST ends. Is there a better way to handle this?
Code Snippet:
Displaying date time using - todatetime(today() - 1) - results as dd/mm/yyyy 00:00 (dd/mm/yyyy 01:00 after daylight saving)
Fixed this using gmt () - gmt(todatetime(today() - 1)) - results as dd/mm/yyyy 00:00 ( do I have to change the code when daylight savings ends?)
OriginalPostID-203712
OriginalPostID-203712
Discussion posts and replies are publicly visible
0
siddharthg837
over 9 years ago
One of the approach to cater this is to change the timezone value prior to storing in database for which you can use gmt() or local() functions. But store your datetime values in the database in GMT to avoid this sort of problems. Please go through time zone context, date and time functions to understand in detail.
forum.appian.com/.../Time_Zone_Context
forum.appian.com/.../Date_and_Time_Functions
forum.appian.com/.../Date_and_Time_Functions
forum.appian.com/.../Data_Types
forum.appian.com/.../Date_and_Time_Functions
The similar post around this which might help you on this:
forum.appian.com/.../e-118813
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jaishankarj
over 9 years ago
@siddharthg837: I am not storing the value in DB but displaying the date time on Interface as I mentioned.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Former Member
over 9 years ago
Is the timestamp being pulled from the database, or is this done all in memory with no database interaction at all -- whether it be SELECT from database or INSERT into database?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jaishankarj
over 9 years ago
@Sean: I am not fetching the value from database neither storing it. I am having an interface where I am displaying the Start Date Time field defaulted to previous day. Before BST the code was working fine but after that it is showing 1 hour ahead time. Hope this will help
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
siddharthg837
over 9 years ago
So when you say you are defaulting your date to the previous day - are you using now() - 1 as your expression to populate the default values?
If yes, try using this to autopopulate the previous day date:
todatetime(local(now())-1).
Not sure if this would help, but I tried using the above for the similar issue in past, and it worked for me.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
akhileshn3539
A Score Level 1
over 9 years ago
As per my knowledge - If you use gmt() function, you don't have to modify your code when daylight saving ends.
Below is the explanation -
What you see on the front end in date and date time fields depends on user time zone. Right way to think about it is to do calculations in GMT and then apply user time zone over the calculations. As the time zone can be different for different users, based on user time zone they will see the difference in displayed date time values.
In your current scenario, when you try to display datetime(today()-1), it calculates to 31/03/2016 00:00:00 GMT considering today as 01/04/2016.
Now, if you login with an user in BST time zone, you will see 'datetime(today()-1) in GMT' changes to '31/03/2016 01:00:00 BST' by adding 1 hour time zone offset to GMT time.
For users in EDT time zone, they will see it '30/03/2016 20:00:00 EDT',
For users in IST time zone, they will see it '31/03/2016 05:30:00 IST'
When we apply GMT function it removes the time zone offset and displays value in GMT.
So, during summers when BST is used, gmt('31/03/2016 01:00:00 BST') is changed to '31/03/2016 00:00:00 GMT'
During winters when GMT is used, gmt('31/03/2016 00:00:00 GMT') remains same as '31/03/2016 00:00:00 GMT'
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jaishankarj
over 9 years ago
@akhileshn583: Thanks for confirming this and the example is nice way to explain things.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel