Jump to content
  • Advertisement
Sign in to follow this  
boolean

[web] SQL: Date by numbers

This topic is 4896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is actually very loosely related to what I am trying to do, but I think it may come up at some point [smile] Say I have a Database with the fields:

  Day  | Week 
---------------      
   1   |  1
   3   |  2
   6   |  3
How could I format this to see the first record (1-1) as the first day of the second week of the year, and output it as '2/1/05'? Is this even possible? Cheers!

Share this post


Link to post
Share on other sites
Advertisement
I don't really get what your asking here, but i'll give it a go anyway :) if you know that Day 1 Week 1 is the 2/1/05 then it would be just a simple matter of figuring out the number of days that make up the next entry.

That is day 3 week 2 would be 3 days + 7 days ( 1 week ) = 10 days, which then gets added to your original date to get the date for this entry. in this case it would be the 12/1/05.

Which database are you using to do this if your using ORACLE or SQL Server it would be possible to do the date addition using either PL/SQL or T-SQL but i would suggest that this calculation is done programmatically so you can support other DB's too.

I hope this helps and i haven't got the wrong end of the stick :)

Share this post


Link to post
Share on other sites
That sounds very close to what I want to do.

I keep forgetting to say each time I post SQL questions, but I am using Access.

Share this post


Link to post
Share on other sites
If you are using access then a simple DateAdd function will suffice as long as you know what Day 1 week 1 date is its just a simple matter of finding the number of days to be added and then doing DateAdd("d", NumDays, Day1Week1Date) to get the required date. You could even create a calculated column that calculates this value for each row using the dateadd function its quite easy. Check out this page for some additional help

m$ access date help

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!