Convert YYYYMM to first date and last date of the month

Database
Highlighted
Enthusiast

Convert YYYYMM to first date and last date of the month

I have a table with the date field in FLOAT datatype which is in YYYYMM format, I want the first date and last date of the month derived.

 

Emp_IDDatefield
123201201.00

 

expected output

 

Emp_IDDatefieldFirst DateLast date
123201201.001/1/20121/31/2012

Accepted Solutions
Ambassador

Re: Convert YYYYMM to first date and last date of the month

Try

Cast((Datefield-190000) * 100 + 1 AS DATE) AS First_date, Last_Day(First_date) AS LastDate

 

1 ACCEPTED SOLUTION
2 REPLIES 2
Ambassador

Re: Convert YYYYMM to first date and last date of the month

Try

Cast((Datefield-190000) * 100 + 1 AS DATE) AS First_date, Last_Day(First_date) AS LastDate

 

Enthusiast

Re: Convert YYYYMM to first date and last date of the month

Thank you! It worked.