Re: covert julian date to calander date

2016-09-21 Thread Erik Cederstrand

> Den 21. sep. 2016 kl. 02.41 skrev sum abiut :
> 
> Thanks Erik, 
> 
> i think that should do the trick.is there a way to covert the date column 
> straight from the sql query or from the template?

If you want to do this from the template, create a custom template tag: 
https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/

I don't have experience with MSSQL, but if you want to convert the date 
server-side, this should work: 
http://blogs.msmvps.com/robfarley/2009/03/25/converting-to-and-from-julian-format-in-t-sql/
 You could add the custom SQL as a RawSQL: 
https://docs.djangoproject.com/el/1.10/ref/models/expressions/#django.db.models.expressions.RawSQL

Depending on how your data is represented, you could also solve this with a 
custom model field: 
https://docs.djangoproject.com/en/1.10/howto/custom-model-fields/ The 
conversion code should go in the from_db_value() method.

Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5FA21E07-B29C-4036-BD7C-9F2DC30993AA%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: covert julian date to calander date

2016-09-20 Thread sum abiut
Thanks Erik,

i think that should do the trick.is there a way to covert the date column
straight from the sql query or from the template?

cheers



On Tue, Sep 20, 2016 at 9:17 PM, Erik Cederstrand  wrote:

>
> > Den 20. sep. 2016 kl. 01.40 skrev sum abiut :
> >
> > Hi,
> > how to you convert from Julian date to a Calender date. I am pulling
> data from an MSSQL and i what to convert the Julian date to calender date
> before displaying data on my template.
>
> If I understand your question correctly, that should be easy. Just convert
> the Julian date to a Python date in your view:
>
>my_date = (datetime.datetime(my_year, 1, 1) + datetime.timedelta(days=
> julian_day)).date()
>
>
> Erik
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/236EFE25-2F80-4247-9972-56DF60C662AA%40cederstrand.dk.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y7Shu8PoqKcP4HSxd3SsAxP%2BDs5aycgDVG4i-voRfWq7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: covert julian date to calander date

2016-09-20 Thread Erik Cederstrand

> Den 20. sep. 2016 kl. 01.40 skrev sum abiut :
> 
> Hi,
> how to you convert from Julian date to a Calender date. I am pulling data 
> from an MSSQL and i what to convert the Julian date to calender date before 
> displaying data on my template.

If I understand your question correctly, that should be easy. Just convert the 
Julian date to a Python date in your view:

   my_date = (datetime.datetime(my_year, 1, 1) + 
datetime.timedelta(days=julian_day)).date()


Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/236EFE25-2F80-4247-9972-56DF60C662AA%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: covert julian date to calander date

2016-09-20 Thread C. Kirby
I've never used it, but this package appears to be made for converting 
between Julian and Gregorian dates
https://pypi.python.org/pypi/jdcal

Good Luck

On Tuesday, September 20, 2016 at 2:42:29 AM UTC+3, suabiut wrote:
>
> Hi,
> how to you convert from Julian date to a Calender date. I am pulling data 
> from an MSSQL and i what to convert the Julian date to calender date before 
> displaying data on my template.
>
> cheer
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4158ea7a-6fce-46a9-bdf5-e0a3bf612278%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


covert julian date to calander date

2016-09-19 Thread sum abiut
Hi,
how to you convert from Julian date to a Calender date. I am pulling data
from an MSSQL and i what to convert the Julian date to calender date before
displaying data on my template.

cheer

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5EMLiy4pxwnFbjheY2kR8VMuKEQzagH8nqMBXwnWNFug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.