Jump to content
  • 0

Make Date Submitted 2 Digits on Table


CaptNemo

Question

2 answers to this question

Recommended Posts

  • 0

Hello @CaptNemo,

As far as I understood you want to add a leading zero to the numbers less than 10.

If so, please test these formulas:

- Hours 

RIGHT('0' + CAST((DatePart(hour, [@field:Date_field])) as nvarchar), 2)

- Minutes

RIGHT('0' + CAST((DatePart(minute, [@field:Date_field])) as nvarchar), 2)

Where [@field:Date_field] should be replaced with your field name.

Link to comment
Share on other sites

  • 0

Hi @CaptNemo,

Here is a formula that you may use to add a leading zero to the numbers less than 10:

-Hours
 

CASE 
  WHEN DATEPART(hh, [@field:Date_Field]) < 10 
  THEN '0' + CAST(DATEPART(hh, [@field:Date_Field]) AS VARCHAR)
  ELSE CAST(DATEPART(hh, [@field:Date_Field]) AS VARCHAR)
END


-Minutes

 

CASE 
WHEN DATEPART(n, [@field:Date_Field]) < 10 
THEN '0' + CAST(DATEPART(n, [@field:Date_Field]) AS VARCHAR) 
ELSE CAST(DATEPART(n, [@field:Date_Field]) AS VARCHAR) 
END

Where [@field:Date_field] should be replaced with your field name.

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...