There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
SQL & ASP: Passing Formatted Now() to a variable


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
smooth's Avatar
Distinguished Member with 3,485 posts.
 
Join Date: Sep 2005
Location: NC, USA
Experience: Learning everyday :)
26-Oct-2007, 08:59 AM #1
SQL & ASP: Passing Formatted Now() to a variable
Hey everybody

I am using ASP with a SQL database and have this code:

HTML Code:
If Request.QueryString("mode") = "exportleads" then
	Set rsUserAdmin = Server.CreateObject("ADODB.Recordset")
	strSQL = "SELECT * FROM leads"
	rsUserAdmin.Open strSQL, conn
	Const ForWriting = 2
	Const Create = True
	Dim MyFile, FSO, TSO, strTime
	[b]Set strTime = Format(Now, "mm_dd_yyyy")[/b]
	MyFile = Server.MapPath("lead_exports/leads_[b]" & strTime & "[/b].csv")
	Set FSO = Server.CreateObject("Scripting.FileSystemObject")
	Set TSO = FSO.OpenTextFile(MyFile, ForWriting, Create)
	TSO.writeline "Name, Phone, Email"
	Do While NOT rsUserAdmin.EOF
		TSO.writeline(Trim(rsUserAdmin("Name")) & ", " & Trim(rsUserAdmin("Phone")) & ", " & Trim(rsUserAdmin("Email")))
		rsUserAdmin.MoveNext
		Loop
		Response.Write ("<br /><br /><div valign='middle' align='center'><a href='lead_exports/leads.csv'>Download File</a></div><br /><br />")
	TSO.close
	Set TSO = Nothing
	Set FSO = Nothing
	strBackup = "INSERT INTO leadarchive(Name, Phone, Email) " & _
				"SELECT Name, Phone, Email FROM leads ORDER BY Name"
	conn.Execute (strBackup)
	strDelete = "DELETE FROM leads"
	conn.Execute (strDelete)
	Set rsUserAdmin = Nothing
	Set conn = Nothing
End If
Now, if I take out the strTime variable and call in the file name it works fine. However, I want to make the filename that is output a unique name everytime, so that I can keep each file on my server. I am getting a error everytime I try to call strTime.

Is there a way to set a variable equal to a formatted Now() function, and then pass it to that filename?
__________________

Meet Your Fellow TSG Members :: Find Out What CWLMST Means :: NCAA Football :: NCAA Basketball


Looking forward to meeting you up in heaven angel

I don't care how bad I feel, when I go to work I make sure I give it my all! Never any less than 12%...

47.5% of all statistics are made up right on the spot

When something is done in ignorance, then its always best to admit that you have no excuse, fix the problem, put it behind you, and move on - valley
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:06 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.