cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert date from month and year?

How to convert date from month and year?

Hi all,

I have imported the data and I have columns Month and year. (Year :  2019, 2020 etc.) and Column "Month" (string format - like "Jan", "Feb", etc.).

Now I need to create new column with acceptable date from these two columns. e.g. if I use from "Year" - 2019 and from "Month" - Nov, I need to get 11/1/2019 and so on.

Can someone help me with this?

Thank you in advance.

Regards,

Praveen



Labels (1)
3 Replies

Hi Praveen,

The function DATE expects a numeric or integer inputs. Day value should be just 1 not "/1/". You need to convert any string values to numeric. The details from our context help are shown below:

DATE
Takes three separate arguments and combines them to form a date in a new DateTime column.
Syntax:

DATE(YEAR, MONTH, DATE)

  • YEAR is four-digit value
  • MONTH is two-digit value
  • DATE is two-digit value
Example:

DATE(@year@, @month@, @day@)

Notes on use:Leading zeros for MONTH and DATE are not supported, for example:
DATE(1999,05,08) should be expressed as DATE(1999,5,8)


With Best Regards
Sudheer Kumar

Hi Sudheer,

I am getting error for the following formula :

DATE(@Month@+ "/1/" + STR(@Year@))
 ↳ Expected three arguments

Regards,
Praveen

Hi Praveen,

You can use a computed column (let's call it New_Date) with the following expression:

@Month@ + "/1/" + @Year@

Alternatively, you can also use concatenate function as well (provided as part of computed column functions):

CONCATENATE(@Month@, "/1/", @Year@  )

If you are planning to use "New_Date" for date-related logic then it's a good idea to convert it into a date.

I hope this helps,

With Best Regards
Sudheer Kumar