-1

Julian Date format 20202800234036

The first four-digit are year -2020

and 356 is the day of the year.

what will be the format for this in mysql to achieve it after taking in 7 first values.

Krishan
  • 33
  • 7

1 Answers1

0

You're looking for str_to_date('2020356','%Y%j') (gives 2020-12-21) , where %Y is the format specifier for a four-digit year, and %j is the day of the year.

For the longer date referenced in your question, just take the LEFT('20202800234036',7) and apply STR_TO_DATE()` to that:

str_to_date(LEFT('20202800234036',7),'%Y%j') -- 2020-10-06

There's a reference for these formats here

  • the Julian format is 20202800234036 we have to take only first seven digits. 2020280 - so i have to split it first, any function for it. – Krishan Mar 10 '21 at 23:11