Jump to content
  • 0

Add days to a date and format it without a timestamp


JKSGT

Question

Hi,

I could do with some wisdom on how to calculate a date. 

I'm trying to set a date in a field using a CASE statement. I have Virtual Field 1 which is capturing today's date without timestamp (pls see image). I also have a number (in this case 30) stored in Virtual Field 4.

I am trying to add the two together and have the result formatted without time stamp (e.g. 25 May 2021) but when I do this I get 31 Jan 1900. See my CASE statement below, the red part is the part that's not working.

CASE

WHEN DateDiff(day, SysUTCDateTime(), [@field:Date_1]) > [@cbParamVirtual4]

THEN DateAdd(day, [@cbParamVirtual4],CONVERT(DATE, '[@cbParamVirtual1]', 103))

ELSE [@field:Date_1]

END

Many thanks

Jay

image_2021_05_26T20_15_10_309Z.png

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello @JKSGT,

It looks like the issue is related to the data type you use in the CONVERT() function.

Please try to convert to the datetime, so the formula have the following syntax:

 

CASE

WHEN DateDiff(day, SysUTCDateTime(), [@field:Date_1]) > [@cbParamVirtual4]

THEN DateAdd(day, [@cbParamVirtual4],  CONVERT(datetime, '[@cbParamVirtual1]', 103))

ELSE [@field:Date_1]

END

 

Link to comment
Share on other sites

  • 0

Also, I wanted to add, that if you set the field that has Date/Time data type to the Calculated Value, you may use the Formatting options. 

You may select the format from Localization or set the Custom format:

j5YJv9w.png

 

These articles can be helpful: 

https://howto.caspio.com/localizations/formatting-options/

https://howto.caspio.com/datapages/datapage-components/field-formatting-options/

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...