I need an SQL string that inserts the current date into a database. So far I have tried: SQL = "INSERT INTO X (START_DATE) VALUES ('" & Date.Now & "')" mycomm = New SqlCommand(sql, myconn) mycomm.ExecuteNonQuery() However, there is a problem with the SQL command. The problem is related to the date. Is there a way of programatically inserting the current date/time into the SQL database? Language used is VB.
I have two fields DSRHADTI which is an isodate and DSRHTIME which is 8 char time field in format 10.31.00. I want to take both these fields and put them into a field that is database timestamp so I have converted DSRHDATI to 10 character field. I am then trying to use substring to put both into 18 character field using derived column transformation editor. but it does not like the below. It's red syntax error what am I missing.
(SUBSTRING(Copy of DSRHDATI,1,4) +' /' + SUBSTRING( Copy of DSRHDATI,6,2) + '/ ' + SUBSTRING(Copy of DSRHDATI,9,2)) + SUBSTRING(DSRHTIME,1,2) + '.' + SUBSTRING(DSRHTIME,4,2) + '.' + SUBSTRING(DSRHTIME,7,2)
One I get the above to work I plan on convert 18 char to datetimestamp.
I am in need of a format string or simple vb code that can add the local time zone to the end of a time field.. Something like: 9:36 AM EST 9:36 AM PST
This timezone will just come from the machine that the reporting server is on. I don't see this listed as a standard format, and I have come up empty so far in my research - anyone got a solution for this?
I need to measure the time between timefield_a and timefield_b. So, I used DATEDIFF (hh, timefield_a, timefield_b)
Now, they said "Our clock starts at 7am, so even if someone enters timefield_a at 5am or 630am, I want that rounded up to 7am, so my clock doesn't start till then".
So, I've been trying to create a case statement that rounds the time up to 7am but still keeps the date in tact. No luck.
I created aspnet DB on SQL Server 2K using aspnet_regsql utility. Everything works fine except the DateTime fields in all tables are using a wrong time zone. How do I set it to use my local time zone? Any help will be greatly appreciated.
Hi can anyone help me with the format of my stored procedure below. I have two tables (Publication and PublicationAuthors). PublicaitonAuthors is the linking table containing foreign keys PublicaitonID and AuthorID. Seeming as one Publication can have many authors associated with it, i need the stored procedure to create the a single row in the publication table and then recognise that multiple authors need to be inserted into the linking table for that single PublicationID. For this i have a listbox with multiple selection =true. At the moment with the storedprocedure below it is creating two rows in PublicaitonID, and then inserting two rows into PublicationAuthors with only the first selected Author from the listbox??? Can anyone help???ALTER PROCEDURE dbo.StoredProcedureTest2 @publicationID Int=null,@typeID smallint=null, @title nvarchar(MAX)=null,@authorID smallint=null AS BEGIN TRANSACTION SET NOCOUNT ON DECLARE @ERROR Int --Create a new publication entry INSERT INTO Publication (typeID, title) VALUES (@typeID, @title) --Obtain the ID of the created publication SET @publicationID = @@IDENTITY SET @ERROR = @@ERROR --Create new entry in linking table PublicationAuthors INSERT INTO PublicationAuthors (publicationID, authorID) VALUES (@publicationID, @authorID) SET @ERROR = @@ERROR IF (@ERROR<>0) ROLLBACK TRANSACTION ELSE COMMIT TRANSACTION
I have a webform that has 2 calendars that i use to insert a dateFrom and dateTo into a sql database table that has the type smalldatetime. When i insert into the database i get yyyy-mm-dd hh:mm:ss but i just want the yyyy-mm-dd not the time. how can i do this with my asp.net c# code? I also has a datetime.Now() that does the same thing.1 string dateNow = DateTime.Now.ToShortDateString(); 2 3 string myConnectionString = @"Data Source=SRVWEB02SQLEXPRESS;Initial Catalog=strukton_se;User ID=user;Password=secret"; 4 5 SqlConnection myConnection = new SqlConnection(myConnectionString); 6 string myInsertQuery = "INSERT INTO jobs (name, description, contact, datePosted, dateFrom, dateTo) Values(@name, @description, @contact, @datePosted, @dateFrom, @dateTo)"; 7 SqlCommand myCommand = new SqlCommand(myInsertQuery); 8 myCommand.Parameters.AddWithValue("name", TextBoxName.Text); 9 myCommand.Parameters.AddWithValue("description", TextBoxDescription.Text.Replace(" ", "<br/>")); 10 myCommand.Parameters.AddWithValue("contact", TextBoxContact.Text.Replace(" ", "<br/>")); 11 myCommand.Parameters.AddWithValue("datePosted", dateNow); 12 myCommand.Parameters.AddWithValue("dateFrom", Calendar1.SelectedDate.ToShortDateString()); 13 myCommand.Parameters.AddWithValue("dateTo", Calendar2.SelectedDate.ToShortDateString()); 14 15 ButtonSubmit.Enabled = false; 16 17 myCommand.Connection = myConnection; 18 myConnection.Open(); 19 myCommand.ExecuteNonQuery(); 20 myCommand.Connection.Close(); Thanks.
My ASP.net project with database connection inside, I mean DataBound or whatever the name is make my website load slower because there's a delay about 8 til 9 seconds when in its first load from localhost, after the first load my ASP.net project run very fast and it just take 1 second or less to reload. The problem will show up again after I restart my computer and trying to load my project from localhost at the first time. How do I make my ASP.net project to load very fast with just 1 second or less at the first time from localhost?
I need to insert rows into a table which contains a smallint field for time. The times are stored in that colum as integers (898, 11345, 1259, etc.) How can I enter a time like 9:15 AM into this field? I know how to display integer data in hh:mm format but I'm stumped on how I can do the reverse.
Hi,I've a strange problem with a INSERT query. It's taking a long time toexecute. The format is like this :INSERT INTO table1SELECT ..FROM table2Executing the SELECT .. FROM table2 is taking 30 seconds. The resultis nothing: no records are selected.When i include the INSERT part it will take 12 hours to completeINSERT INTO table1SELECT ..FROM table2There's is an index on the table and when i delete it, it gives stillthe problem.Keh?Greetz,Hennie
My time dimension has date mm/dd/yy 00:00:00 where as the source has mm/dd/yy and some time not 00:00:00 I am sure the iserts in fact table are failing. I do not want the time part to come anywhere in data mart. what should i do in SSIS.
Clean vista install, Clean full office 2007plus install Clean visual studio 2008pro install Many failed sql 2005dev installed, did SKUUPGRADE-1 Now have office2007 Smallbiz, VS2008pro, SqlExpress and sql 2005dev installed. Note outlook 2007 error on first run after sql2005dev. Seams to have broken and created a new sql connection, don€™t think its the original. but that€™s not the current issue ! web admin page error, could not connect to db I did regsql.exe from the net dir and the web admin work and the db is created for roles and such in vs 2008 via web admin page and mssql. Managed to create db in apps data folder and modify connection in server explorer. Added table to aspx page from apps folder and it runs via f5, but errors under localhost. €œCannot open user default database. Login failed.€? €œLogin failed for user 'NT AUTHORITYNETWORK SERVICE'€? Have seen some reference to iis permissions, but not sure what to change? Is it a file level permission, a virtual permission Works in vs2008 using f5 run! http://localhost:50115/vs2008/ Can work with apps folder db file in vs 2008 server explorer Had to modify db connection back to sqlexpress in server explorer Can work with db in sql management studio, have three local instances; Pc Pcsqlexpress Pcsmallbiz Can display db data in aspx page via f5 , but not localhost unless vs2008 is not running!!! Have not been able to make vs2008, Sql2005dev, sqlexpress all work together using iis in vista via localhost and vs2008 f5 at same time?? Can€™t do anything with db in solutions explorer, but can work in server explorer if I modify connection back to sqlexpress Can€™t display data aspx page via localhost http://localhost/vs2008/ Cannot open user default database. Login failed. Login failed for user 'NT AUTHORITYNETWORK SERVICE' Localhost works in iis via virtual directory if I remove db grid in page or vs is not running Could someone test and tell how to use all of these together? What is going to happen if I get it to work local and then try to upload to shared host? <connectionStrings> <remove name="LocalSqlServer" /> <add name="LocalSqlServer" connectionString="Server=wabpc;Database=VS2008test;Integrated Security=true" providerName="System.Data.SqlClient" /> <add connectionString="Server=SQLEXPRESS;Database=Database.mdf;Integrated Security=true" name="sqlexpress" />
</connectionStrings> If I close vs2008 and the management studio, localhost works and displays the db info!! Open vs2008, modify connection back to sqlexpress and the aspx page breaks via localhost Close vs2008 and local host works Open vs2008 and get a error 25 in server explorer connection string invalid, but f5 works after the offline clears. I change db connection back to sqlexpress to work with db in server explorer! That breaks localhost, but f5 works
I am looking for a way to retrieve the time from a Sql 2000 database in the format of hh:mm AM or PM. I am storing the information as a "datetime" data type. If I only supply the time (such as 02:30 PM) then the date defaults to 12/30/1899. When I read the information from the database I get "1899-12-30 14:30:00:000".
If I enter 02:30 PM I would like to get 02:30 PM.
I have tried various convert functions in Sql, maybe there is a way to format with an ASP.Net datetime function but I need help to get the information back in the right format. Thx In Advance
I am taking datetime value from a table MA and separating date and time by using CONVERT function.
CONVERT(VARCHAR(12), MA.ArrivalDate, 101) AS ArrivalDate, ' CONVERT(VARCHAR(12), MA.ArrivalDate, 108) AS ArrivalTime,
but my ArrivalTime is coming as 13:01:00. I want to convert this time as 1:01:00. I have to do this conversion in my stored proc, not in my code. can you help ..? Thanks
we have a column in database named "time" but it stores value as VARCHAR(9) datatype, when i display the "time" field (let us say "time" value is 07:54 AM) on reports, it displays the value as it is (07:54 AM) but i need the value to be displayed as 7:45 AM on the reports.
how can i do that ? clearly
field in the database is TIME (varchar(9)) 07:45 AM must be displayed as 7:45AM 12:34 PM must be displayed as 12:34 PM I tryed to write a function in sql reports properties code which acceptes array of charecters and depending up on the value of left most charecter of recieved array it will return charectr string back, but coulded get it worked
Hi, I want ot get time just like this : 8:40:15 AMI am using select convert(varchar(12),getdate(),8) to get this but this function return 24 Hrs format. How to achive this by using small coding. Jasim...
I have a sql table setup with a date field and a time field. They are both set to datetime.
In my net form, the date is entered as a date and gets added the the SQL table OK.
My problem is the time field. If i enter it straight into the SQL table as say 2pm, it adds it correctly as 2:00:00 PM. When I try to enter the time through my VB.net webform, the time gets added ok, but it places the date in the field as well to look like 14/04/2004 2:00:00 PM, I only want the time part of the field.
My code to add the time to the SQL table is as follows,
When I edit the recurring job schedule for a job, I try to set a job run in daily frequency at 11:00 am . But I can only edit the field in "11:00:00" and it always run at 11:00pm. Can someone know to set it run at 11:00am.
In SQL Server 2000 we are loading data into a smalldatetime field. The file is being loaded from a text file that contains the date in the following format: 07/24/2000 16:08
The problem occurs when the data is as follows: 04/28/2000 14:60
Microsoft SQL Server6.5 was forgiving and would translate this to 15:00 upon load but SQL Server2000 is failing with the Invalid Time Format error.
Can anything be done to force SQL Server 2000 to recognize this?
What do you think of a query that generates aSystem.Data.SqlClient.SqlException when submitted via a application,but when run through QueryAnalyzer or EnterpriseManager doesn'tgenerate a error? Here are 2 examples of the query:SELECT table1.*,table2.field1,table2.field2,table2.field3 FROMtable1,table2 WHERE table1.field1 = table2.field1 ANDtable1.field2='103' ANDtable2.TStamp > '12/19/2005 12:20:14 PM' ORDER BY table2.TStampSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '12'.SELECT table1.*,table2.field1,table2.field2,table2.field3 FROMtable1,table2 WHERE table1.field1 = table2.field1 ANDtable1.field2='103' ANDtable2.TStamp > '12/8/2005 8:29:43 AM'ORDER BY table2.TStampSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '8'.I believe the error is referencing the hour portion of the timestamp.When I run these queries through QA/EM I don't get a result set ... somaybe those apps just trap the exception and ignore it. Still, seeanything wrong with the TStamp?
I have a DateTime parameter called End Date set up with a default value eg =DateAdd("s",-1,Today). When I preview, the default value appears as 19/09/2006 23:59:59, which is fine.
However, when the report is deployed, it is displayed as 19/09/2006 11:59:59 PM. This would also be fine, except when the user changes the date using the calendar, it converts the time back to 24 hour time - eg 19/09/2006 23:59:59. Then when the report is run, it converts the time format back to AM/PM again.
Also, I have a Start Date Parameter, with a default value of 12:00AM today. I would like this to be displayed as 19/09/2006 12:00AM in the Start Date parameter text box, however reporting services will not display the 12:00AM part. Using FormatDateTime in the Default value will return a string and cause an error. I don't want to change the parameter to a string and lose the date picker.
Any ideas,
Thanks
PS Getting the Date/Time settings changed on the reporting server would be extremely difficult!