Using If Else statement I'm comparing "expire date time" column with a current date before submitting the newform.aspx,

but if I put the expire date time at 8am with the condition (current date<=8am) using "PreSaveAction" function, newform is saving the list values till 7:59 am in stead till 8am (since I'm using <=8am) loosing one minute here. I want to save the values until 8am.

how should I make this work? any help, please.

  • Where is the IF statement? In JavaScript code? In a Calculated Column? In a Workflow? – Mike Smith - MCT - MVP Jan 28 '18 at 18:34
  • Depending on how you are testing, it's unlikely that you will ever hit exactly 8:00 AM. SharePoint DateTime is represented internally as a number (42,763.9461689815 for example with 42763 days since day "0" plus a fraction of a day the .946...) put you a fraction of a second before or after 8:00 AM. 8:00AM is 8/24ths of a day, so 0.33333333333333. So today at 8:00AM was 43128.3333333333. I use this numeric aspect of dates to create (pseudo) random numbers in a calculated column: techtrainingnotes.blogspot.com/2016/11/… – Mike Smith - MCT - MVP Jan 28 '18 at 18:45

If you are looking to round down to the nearest minute, you could use this in a Calculated column (assuming your column is "Created"):


It sets the second to zero.

| improve this answer | |
  • Hi mike, I'm not using calculated column, it is date time (expire date time) type manually enters in another list, I'm just retrieving it from another list and assigning it in another list that I wanted to check that expire date column with current date whether it is past the dead line or not, – sammen Jan 29 '18 at 6:25
  • so everything is working fine with the "PreSaveAction" function it is checking the expire date time with current date time before saving the item,. only issue if I put the expire date with time 8am (if else statement)it is taking until 7:59 loosing one minute here. I want it to be worked as it has 8am expire date. if any solution would be greatly appreciable. thanks so much – sammen Jan 29 '18 at 6:25
  • and it is javascript – sammen Jan 29 '18 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.