Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get Last week

Status
Not open for further replies.

deejayAr

Technical User
Mar 20, 2008
126
US
I have two input fields and want to fill these fields as
start last week=== Last week Monday's date
end last week == last week sunday's date

any help would be nice...
thank you...
 
Hi

JavaScript:
[b]var[/b] d[teal]=[/teal][b]new[/b] [COLOR=darkgoldenrod]Date[/color][teal]()[/teal]
d[teal].[/teal][COLOR=darkgoldenrod]setTime[/color][teal]([/teal]d[teal].[/teal][COLOR=darkgoldenrod]getTime[/color][teal]()-([/teal]d[teal].[/teal][COLOR=darkgoldenrod]getDay[/color][teal]()?[/teal]d[teal].[/teal][COLOR=darkgoldenrod]getDay[/color][teal]():[/teal][purple]7[/purple][teal])*[/teal][purple]24[/purple][teal]*[/teal][purple]60[/purple][teal]*[/teal][purple]60[/purple][teal]*[/teal][purple]1000[/purple][teal])[/teal]
field2[teal].[/teal]value[teal]=[/teal]d
d[teal].[/teal][COLOR=darkgoldenrod]setTime[/color][teal]([/teal]d[teal].[/teal][COLOR=darkgoldenrod]getTime[/color][teal]()-[/teal][purple]6[/purple][teal]*[/teal][purple]24[/purple][teal]*[/teal][purple]60[/purple][teal]*[/teal][purple]60[/purple][teal]*[/teal][purple]1000[/purple][teal])[/teal]
field1[teal].[/teal]value[teal]=[/teal]d

Feherke.
 
Thank you very much for your reply
but it is giving me
start last week=== Last week thursday's date (02/02/2012).
end last week == last week today's date (tuesday (02/07/2012).

what I need

start last week=== Last week Monday's date (start from Monday.. e.g 1/30/2012)
end last week == last week sunday's date e.g (end on sunday.. e.g 02/04/2012 )

all I need last week start form monday and end on sunday...

you are very close would you please take a look
and correct it..

I appreciate your help

 
Hi

Show your code. Specify the used browsers.


Feherke.
 
var d = new Date();
d.setTime(d.getTime() - (d.getDay() ? d.getDay() : 7) * 24 * 60 * 60 * 1000);
jQuery("#DateTo").datepicker("setDate", d);
d.setTime(d.getTime() - 6 * 24 * 60 * 60 * 1000);
jQuery("#DateFrom").datepicker("setDate", d);

I have to support ie and foxpro as well

thanks
 
Thank you very much FEHREKE,
I really appreciate that you spare some time to help me..
Problem was in my end….
Now it is working...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top