Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    ASP




If Then With Date


I have a basic if/then statement:Code:

if rs("Date") = "10" Then
date_link = "<a href=http://www.link1.com/"
Else
date_link = "<a href=http://linke2.com="
End if

"Date" reads as 10/1/06. I want to say that any dates that start with "10" get a specific link, any dates that start with "11" get a specific link and so on.. What do I write?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Check The Date Difference Between The Current Date And The Booking Date?
I am developing a simple booking system where I had a booking date. The problem is I want to make sure that the user must book 3 days in advanced for certain room.

I have tried to use DateDiff but it seems doesn't work. Actually i just 1 to make sure that the user must book 3 days in advanced from the current date. I am wondering whether there is anything goes wrong in my datediff function. Code:

Select Statement Comparing Date() & Date Field Of Database
i'm new here and i'd like to ask if there's someone who knows how to compare date() function and date from database with date/time type inside select statement so i don't have to do if..then..else

Date Problem (wrong Date Inserted When Updating)
sql = "UPDATE Marknad SET" _
& " Typ ='" & Typ & "'" _
& ", Modell ='" & Modell & "'" _
& ", Arsmodell ='" & Arsmodell & "'" _
& ", Beskrivning ='" & Beskrivning & "'" _
& ", Stad ='" & Stad & "'" _
& ", Prisidé ='" & Priside & "'" _
& ", Fornamn ='" & Fornamn & "'" _
& ", Efternamn ='" & Efternamn & "'" _
& ", Telefon ='" & Telefon & "'" _
& ", Epost ='" & Epost & "'" _
& ", Datum ='" & Datum & "'" _
& " WHERE (((Marknad.Annonsnr)=" & Request.QueryString("id") & "))"
DatabaseConnection.Execute sql

---

Above does work as I want it to do BUT it inserts 1/8/2006 instead of 8/1/2006 as it should!

The best thing would be to exclude the date from updating at all, but when taking away the line:

& ", Datum ='" & Datum & "'" _
It gives an error... how do I solve this?

I forgot, you might want to see this:
Datum = date

Getting Week Start Date And End Date By Entering Weeknumber
In my page i have two combobox. one for year and one for week numbers.Now my prob is

1.when i select a year from combo box 1, second combox box will display the number of weeks in that year.eg if i select 2005 it display me list from 1 to 53 as there are 53 weeks in 2005.

2.when i select a weeknumber from combobox 2 and press submit button it ll display start date and end date of entered week.

Compare Server Date With Date String
I am trying to compare two dates. My problem is no matter what the value of mydate, it is still fall in the first IF statement condition (even if mydate is 10/10/2004). Any advise for this matter?

mydate = "6/6/"&year(date)
IF date() <= mydate THEN
response.write "first half of the year"
ELSE
response.write "second half of the year"
END IF

Comapare General Date With Short Date
I am trying to construct an SQL statement that can grab all of the entries out of a table, where the Date field consists of today's date. The Date field is called 'DateTime' - and it is in a General Date format (DD/MM/YYYY HH:MM:SS). I obviusly want to use an SQL statement like this:

SELECT * FROM tblExample WHERE (DateTime = Date());

However, that wont work because Date() will only return a short date (DD/MM/YYYY).

Date Picker - Making The First Date Five Days Away
I would like to modify this so that the first available date that can be selected is five BUSINESS days out. The script only shows Mon-Fri so if the date is Tue Jul 13, 2004, Tue Jul 20, 2004 needs to be displayed. Code:

Compare A Date In My Database To The Current Date
I am trying to compare a date in my database to the current date. MySQL statement is:

sqltemp5="select * from users where dateclosed <= '" & date & "'"

What I am trying to accomplish is exclude records where the dateclosed field is older than todays date. Such as if dateclosed = 6/30/2004 then today being 08/25/2004 that record should be excluded.

MS SQL Database Field Date Comparison To Date()
In a connection string, I have the following:

sql3 = "SELECT DISTINCT State FROM Property Where TypeID = '" & srch_cat & "'"

In the database, is a field called expiredDate I am trying to show only records whose expiredDates are greater than todays date, but I am messing up somewhere. The values in the fields are as this: 3/7/03 (or something like that...no time is added to it)

Comparing A Date Field To A Date In A Form.
"SELECT id, title FROM Businesses WHERE Date_Added >= " &
Request.Form("Since_Date")

This SQL string returns all records from the table Businesses and does
not seem to be able to recognise Request.Form("Since_Date") as a valid
date. The Since_Date value is entered into a form field as
"01-Jan-2005" and appears to be treated as a date; when viewing the
SQL statement(with a response.write) it shows the date as 1/1/2005
even if it is entered into the form as 2005/1/1

I've also tried CDate(Request.Form("Since_Date")) with no luck,
although this was the treatment that worked when the SQL statement was
running in an .idc file.

Date_Added is a regular DateTime field in an Access 2000 database

Any suggestions please ?????

ASP Date: Get Records With Date = Today (SQL Server)
I'm trying to get all records from my SQL Server Database with
"DeadlineDate" = today (not today - 24 hours).

All records has a field called "DeadlineDate", and the date is stored in
this field like this: 13.08.2005 07:00:00

I dont care about the hours (Ex: 07:00:00), just the date (ex: 13.08.2005).
This is the SQL I have made, it gets all the record with the date = today -
24 hours... but that is not what I want.

sql = "select title from tblProject where (deadlineDate BETWEEN DATEADD(d, -
1, GETDATE()) AND GETDATE())"

How can I get just the records that has the date = today's date??

Data From Date/time By Date
How do i select all records from a table that has a datetime field in it by date.
so i want all the records that was created today.

if i put only the date it doesn't work. this is what i have:

Code:
strsql = "select cnum from [topline data] where cnum = '" & cnum & "' and activerecord = "& activerecord & " and timestamp <> '12/10/2007'"

How To Convert UK Date To US Date Using .asp & MS Access
I have built an online booking system for a hotel and all is working fine except for the fact that the ‘From’ and ‘To’ dates are saved in the MS Access database in US format. The user selects from a date picker pop, which places the in the textfield as English format e.g. 02/12/2007.

However when I try and save this value into the date column in my DB I obviously receive an error because the formats are different. Please could someone advise me on the best way to convert an English date to a US in order to insert this into the DB using ASP & MS Access.

At the moment I am using plain text as the column type, but this is not ideal as I want to start to run queries against the 2 dates.

Recordset To Only Contain Current Items (i.e. If Date Of Item Is Past Current Date)
I have a noticeboard that the user inputs items into. One of those is the date of an event. Once that event has passed I want it to disappear from the page.

So I need to do a comparison with current date to the date in the "datestarted" field. My table is called "notices." Using Access and ASP VBscript.

Start Date Should Be Less Then End Date
Uust wanna check that the start date should be less then End date... does any one has javascript for this or any website ...

MySQL Date To ASP Date
I found some script that converts ASP to MySQL. Now I need to reverse that process.MySQL Order_Date is the field I need to convert.I have a select list for order nunber - 'order date Where order date = MYSQL date stored in db.Sounds simple enough, but is very difficult so far to implement.

Asp /sql Date
I’m trying to put into my SQL DB. An ASP now() for mated varaible: IE: mm/dd/yyyy hh:mm:ss where as the My SQL datetime fields take the format of yyyy/mm/dd hh:mm:ss Is there any way to format the date for the My SQL ? Or do I have to tare it apart with left and right and rebuild it in the correct format…..

Day/date
is there a way of working out the day of the week ie Monday Tuesday etc from a date?

Date Become PK
if i use date become a primary key, i cannot delete and update but i can only insert the data.

is it become i need to convert it when i want to update or delete? becoz when it retrieve it, it would surely be a string?

Date
My prob now is i there's no date entered in the DB, there will be nothing displayed at the edit page. Say for example date of departure for employee.

If nothing is selected and therefore entered, the value in the DB should be empty. Therefore when I try and retrieve the date of departure, the drop down list should be at it's default(mayb in this case "select one"). Code:

Date
i want to store a date 8 july 2005 12 noon in a variable what i want to do is check if the current date is less then 8 july 2005 and time 12 noon

then i want to display a message i am having problems store 8july 2005 12 noon in a variable any ideas.

Date
I know this is a simple questions, however I forgot how to extract the Month from the date. I've tried a few things such as Code:

Left(date(), 2)

and other variations of that nature. Basically what I'm trying to do is to pull the month from the date in either a number sequence or in long format. I run into problems with the left(date(),2) code when the digits are single then turn into a double.

Date
I want to put the simple date asp code on my website.I know what the code for it was but how do i apply it.Do i write it as a seperate asp file and link it externally like a css file or do i just put the code in my html where i want it to go.

Date In ASP
I need to compose a date with a couple of stringfunctions, but I dont know the syntax.
I have intDay, intMonth and intYear is my ASP script. These come from a user. I need to form a date with these. The problem is that the user can fill in day=01 or day=1. So I need to remove the leading 0 if there is one.
I need to form a date like this: mm/dd/yyyy. For example 2/2/2003 or 12/24/2003 or 1/12/2004.

Date?
i have a search that searchs a database for records by date, the database stores dates in the form 25/12/2005, i am currently using where curdate is the variable form a form

curdate1=day(curdate)&"/"&month(curdate)&"/"&year(curdate)

and this to select it

sSQL="select * from downtime where Entrydate = #" & curdate1&"#"

is there anyway to correct the dates at the start of the month ie when i put in 30/11/05 it works but when i put in 06/12/05 it dont but if i reverse the last one it does?

Date
I have a form field area that I need to always have display the
upcoming thursday date. ie. this week I would need the form field
area to display 3/1/2007. Then beginning on the Friday 3/2/07 i need
it start displaying 3/8/2007.

Date And Now !
I have stored a date value using the now function.
This stores dates like this: 5/3/2004 3:59:23 PM

I am wanting to run a query that compares todays date with the date in the
db field.

I imagine this means i have to isolate only the date section of the input
saved by using 'NOW()' Using jetsql which would be the best way to accomplish this.

Date In ASP
I have used vv as a date but when i compare it in an SQL statement, it displays an error i.e. that vv is not a date...!

dim vv
vv=formatdatetime(cdate(request.querystring("btn")),2)

ASP Date
I face the problem on datediff function

01 Jan 03 to 28 Feb 05

I would like to get the answer is 2 years and 2 months.how can i do that

Date
objRs.Open "SELECT * FROM staff_movement WHERE EID="&EID&" AND (dateOfAbsence<='"&date&"' AND endofAbsence>='"&end&"' )AND Territory='"&terrCode&"'",objConn,adOpenDynamic

im using asp+sql server 2000 and i nid help with date comparision operators..
the code above basically works if the start and end dates are in the same month

e.g

date and end are both 5/24/2005.. it manages to retrieves records with start date of 5/23/2005 and end date of 5/31/2005

however.. i have a record with start date of 5/24/2005 and end date of 2/6/2005 , and it fails to retrieve the record.

Could Not Get Date
I could not get date from the Microsoft Access table named "TableDate" but i can get myYear and myMonth. any idea?

myDate= Date(rs("TableDate"))
myMonth= Month(rs("TableDate"))
myYear = Year(rs("TableDate"))

Date
remove these extra Zeroes in the date.Now i want the date to be converted from this form to the other form state:
09/06/2006 TO 9/6/2006

If THIS Date Is Less Than THIS Date,
I'm trying to do a simple If...Then statement...

If THIS date is less than THIS date, then...

Here's how it would look in plain english:

If LastActive("last_active") < CommentsRS("date") The <img src="NEW POST" />Else <img src="NORMAL POST" />
End If

I run a big site, so I can't just test that out...

Getting A Date
I wanna know guys i know that

<% =date()%>

will get me 4/19/2006.but i want 04/19/2006.How do you do this in ASP?

Date
I have the following:Code:

Response.Write(Day(rs.Fields("report_period")) & "-" & MonthName(Month(rs.Fields("report_period")),1) & "-" & Year(rs.Fields("report_period")) & ".")
Which displays the date as 4-Aug-2006. Cool. Here is my questions, how can I make the year a two-digit display. I have been looking at home samples, but I can't get it to work. I need it to display like this:

4-Aug-06

Add Date
I have a string that write a csv file to a dir. I would like to add the current date to the end of the string the file name would be commitment"Then the date it was created".csv

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

strFileName = "commitment"'here you can create the file name dynamically if you want

strPathString = "F:UsersOfficecsv_files" & strFileName & "addcurrentdatehere.csv"
RESPONSE.WRITE(strPathString)
Set objFile = objFSO.CreateTextFile(strPathString, True)

Date
if i use now() it will appear as 9/4/2007 10:00:20 PM . is there anyway i can get 09/04//2007 10:00:20 PM

If Date
I am have a database with employees on contract. When the contract date hits, I want the word expired next to the contract date. I have this but it doesn't seem to do anything.

<% If rsTemps.Fields.Item("Contract_terminates").Value = " Date()" Then Response.write("Expired") %>

Date
i am coding to let the user enter 2 dates.The date format is dd/mm/yyyy but in mysql database the formate is yyyy/mm/dd so how do i convert to the format dd/mm/yyyy ?

Date
Im haing issues with dates, theyre swapping between us and uk formats so things are being displayed as the 1st jan or 5th may (01.05 or 05.01) theres no logic to it, and its totally random displaying it correctly one minute and incorrectly the next.

Date
I am developing a community based calendar of events using asp and access. Since some events span several days my client wants a starting date and an ending date. (I have classified these fields as 'date' in access) .

My problem is going to arise when I try to search the database by date: if an event has a staring date of 01/20/05 and an ending date of 01/25/05, how would I get this event to show up if a user searches for a particular date that falls in between (e.g., 01/23/05 )?

Date
datepart seems can't able to detect / differenticate which one is month and day. It got confuse. I have downloaded a few cool / great calendar javascript like from Tigra and it produces this date format (dd/mm/yyyy). But when I want to save it into my Mysql field (the datatype I use is date), it will get a little confuse, sometimes the mm will become dd and vice versa.

I wonder if any of you all face before the same problem. How do you fix this problem? Changed the date input format to become format like 1 May 2004 and then convert it into dd/mm/yyyy?

The way I use datepart is
rs("order_date") = DatePart("YYYY", strOrderDate) & "/" & Right("0" & DatePart("D", strOrderDate),2) & "/" & Right("0" & DatePart("M", strOrderDate),2)

Date
I'mgetting data from SQL server is not a date field. BUt they can input dates. I want to get all dates greater than 11/07/2006 and the item is a valid date. I've used isDate which works but when i get to the part where the greater than computes it writes the date out . Code:


<% If isDate(svc_SDate) > "11/07/2006" then%>
<%= outputDate(svc_SDate) %>
<% Else %>
CMPL
<% End If %>

Date
I am trying to get today's date in this format:

MM/DD/YYYY

The Date Function in VBScript returns a format like:

M/DD/YYYY if the Month is less than 10 .. how can I get today's date in the MM/DD/YYYY Format every time for that is how I have records in the database.

Date Format
I have a form and I request a date. I want the slashes(02/25/2005) to auto fill in the form. Can this be done? How?

Date Format
when some data is being into my database, most of the data is recieved from a form.
2 of the fields are dates, but looking at the db (access) the dates are stored in the '38307' format. - is this the standard way access stores dates?

Now, how do I get it to enter /todays/ date into a column? I thought it would be something like
RecordSet.Fields("LogDate") = today()
but this is wrong, right?

The other date, is to be entered by the user in the form. Now, what is the best way of going about this? It will be in a different column, but in the same format. My default, it would be 'todays' date, but needs the option of being changed. Any ideas? Code:

Date Prob
In Sa the date format is dd/mm/yy. in sql server the format the format
is mm/dd/yy.

What code can be used to chnge the format to the SA date format
eithout chnging sql servers regional settings?

Date/time
I have a simple asp script that pulls data from an ingres database and
displays it on screen.

It all works fine except for date/time fields where the date >=
24/10/2004 and <= 31/10/2004 where it takes 1 hour off the time ie

in the database I have 24/10/2004 08:00

the asp displays 24/10/2004 07:00

The same thing happens for the same date next year.

Any thoughts?

Get Weeknumbers From A Given Date In ASP.
I´m trying to get the weeknumber fom a given date but at some dates
will return the wrong weeknumber.

WeekNumber = DatePart("ww", TodayAsDate, vbMonday, vbFirstFourDays)

like 2003-12-27

I know that this is a Microsoft bug but i have tried their soultion
http://support.microsoft.com:80/sup...s/q200/2/99.asp

but still it will return strange weeknumbers at some dates.


I want the output in weeks from 1 - 52 and every week starts with a
Monday.

Does anyone have a good function to output the weeknumbers from
a given date?


Copyright © 2005-08 www.BigResource.com, All rights reserved