[web] SQL: Date by numbers

Started by
4 comments, last by technomancer 18 years, 11 months ago
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!
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 :)
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.
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

rofflecopters! That was simpler that I thought!

Thanks mate [smile]
no worries :)

This topic is closed to new replies.

Advertisement