Date And Time Best Practice - Storage In SQL Server Database

Jul 27, 2007

With regards to time zones, daylight savings, and web users, is there a best practice for storing date & time information in a database?

For example, my databases are hosted in Time Zone A, but the web users are in Time Zone B.  Then, when I create a rss feed (which is displayed in GMT), I add a third time zone into the mix for the same data.  To date (no pun intended), I have been entering the date/time data in the time zone of the database server (Time Zone A), and then converting it using an application setting in the web.config file (i.e. TimeZoneBOffset = -1, GMTOffSet = -5).  In other words, each time I display a date I calculate what it should be using the time-zone offset in the web.config.  This also enables me to account for changes in day light savings, etc.

My concerns are three fold:  1. What if I move the database to another server and the time zone changes?  2. Right now the users are in only 1 time zone.  If I expand it to several then the offset will have to be by users, which is do-able, but something I haven't had experience with in the past.  3. It is likely more efficient to calculate the time zone once on input into the DB, rather than in each use like I'm doing now.  What time zone baseline for insert into the db should I use?

Thanks in advance for your help!

PS My application is primarily looking at 'smalldatetime' data - down to the 'minute' level.

 

 

View 6 Replies


ADVERTISEMENT

Insert Date And Time To Sql Server Database

Mar 29, 2005

hi guys
im having real problems and dont know how to solve it at all
i have a web app which allows users to enter information through edit boxes
when they submit the imformation it gets added into my SQL database. 
does anyone know how to get the Date and Time when they insert the information  and store in another column of type datetime in SQL database
the web app is written in C#
hope someone can help
thanks

View 4 Replies View Related

Conversion Of Oracle Date Time To Sql Server Date Time In SSIS

Jun 30, 2007

This is driving me nuts..



I'm trying to extract some data from a table in oracle. The oracle table stores date and time seperately in 2 different columns. I need to merge these two columns and import to sql server database.



I'm struggling with this for a quite a while and I'm not able to get it working.



I tried the oracle query something like this,

SELECT
(TO_CHAR(ASOFDATE,'YYYYMMDD')||' '||TO_CHAR(ASOFTIME,'HH24:MM : SS')||':000') AS ASOFDATE

FROM TBLA

this gives me an output of 20070511 23:06:30:000



the space in MM : SS is intentional here, since without that space it appread as smiley



I'm trying to map this to datetime field in sql server 2005. It keeps failing with this error

The value could not be converted because of a potential loss of data



I'm struck with error for hours now. Any pointers would be helpful.



Thanks

View 3 Replies View Related

Inserting The Current Date And Time Into SQL Server Database

Mar 30, 2007

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.

View 1 Replies View Related

Changing Database Server Locale Date Time Settings ?

Jun 15, 2007

Hi There



We currently have the following scenario:

4 app servers with regional date and time settings of locale A.

1 database server with locale settings B.



What is happening is that timestamps are being generated on the app servers, these are then in a sql command which fails on the database server since the timestamp format is invalid.



It was suggested that we change the regional locale settings of the database server, but will this not have serious implications , for example every current timestamp format in the datbase will become invalid?



In a nutshell is it safe to change a database servers regional date time locale settings ? Or are there serious implications?



Thanx

View 1 Replies View Related

SQL Server 2008 :: Loop Through Date Time Records To Find A Match From Multiple Other Date Time Records?

Aug 5, 2015

I'm looking for a way of taking a query which returns a set of date time fields (probable maximum of 20 rows) and looping through each value to see if it exists in a separate table.

E.g.

Query 1

Select ID, Person, ProposedEvent, DayField, TimeField
from MyOptions
where person = 'me'

Table

Select Person, ExistingEvent, DayField, TimeField
from MyTimetable
where person ='me'

Loop through Query 1 and if it finds ANY matching Dayfield AND Timefield in Query/Table 2, return the ProposedEvent (just as a message, the loop could stop there), if no match a message saying all is fine can proceed to process form blah blah.

I'm essentially wanting somebody to select a bunch of events in a form, query 1 then finds all the days and times those events happen and check that none of them exist in the MyTimetable table.

View 5 Replies View Related

Can't Install IBM Tivoli Storage Manager Server On Windows 2003 X64 Storage Server, How Can I Fix The Pkg?

Jan 14, 2008

I am a Windows developer for the IBM Tivoli Storage Manager Server (TSMS) product.
Our product installation is built with InstallShield and uses the Windows Installer.

On a new installation of Windows 2003 x64 Storage Server R2, at a customer's site, the TSMS product fails to install.
The install of the OS has version 3.01.400.3959 of the Windows Installer and I see no newer version that installs.

Part of our product is 32 bit (console) and another part is x64 (server).
When installing I can see that the install's default is being redirected/reset to C:Program Files (x86)TivoliTSM after it is explicitly set by a custom action to ..Program Files.. . I further observe that our custom actions to write 64 bit registry entries are being refused.

REGSAM samMask = KEY_ALL_ACCESS;
if ( regIsWow64Process () ) samMask = samMask | KEY_WOW64_64KEY;
lStatus = RegCreateKeyEx( hLocalConnectKeyRoot,
szSubkey,
0L,
NULL,
REG_OPTION_NON_VOLATILE,
samMask,
NULL,
hKey,
&dw ) ;
The above fails to create the key.

We have tried four versions of our TSMS spanning many changes but the install acts the same.
This does not happen on any other Windows OS we test on but we do not test on Windows 2003 Storage Server R2 being that it is an OEM product. We did test on Windows server 2003 R2 x64 and do not see this problem.

Do you have any suggestions on how to tackle this problem?
I have full installation traces but can only see that the registry work is being refused. I can't see why.

View 1 Replies View Related

Database Storage Limitations In Sql Server

Feb 1, 2005

Whats the limitations of data storage in sqlserver DB. How will be the perforamcne if i have database which will get a data of 400 GB per year and all the data should be there in the table the whole year and then it can be archived.

View 2 Replies View Related

Planning Database Storage For SQL Server 2005

Feb 13, 2008

Here are my planning details:

RAID 1:

2 disks RAID 1 for OS and BINS
2 disks RAID 1 for Backups.

RAID 10

4 disks RAID 10 for data
4 disks RAID 10 for log
4 disks RAID 10 for TEMPDB

Should i put the master and other system database on RAID 10 along with TempDB.

Or what else a guru fellow will advise in above setup.

thanks,

View 5 Replies View Related

How To Get The System Date And Time Into Database

Jun 3, 2007

  Hi, I m using ASP.NET with C#. I m having one field which should store the datetime of the system. The datetime should be automatically stored for that entry when the user submits that record on the click event.Then it should display the date time on the gridview from database.I m using sqlserver 2005 and i have created the stored procedure for the insert command.This
is the sample sp what should be written here to insert system date time
automatically when the user submits the asp.net form ?Is there any code for writing directly in stored procedure or asp.net coding page...  ALTER PROCEDURE [dbo].[StoredProcedure1]@salesid INT OUTPUT,@salesdate datetime,@customername varchar(20)ASBEGINSET NOCOUNT ONBEGIN INSERT INTO sales (customername) VALUES (@customername) SELECT @companyid = SCOPE_IDENTITY()END SET NOCOUNT OFFEND Thanxs in advance...  

View 2 Replies View Related

Date Time Of A Backed Up Database

Apr 10, 2007

Pls tell me,can we store or determine the date/time of a database backed up or can we store date/time while taking back up of a database

View 2 Replies View Related

Insert Date / Time Data To Database

Jun 3, 2014

I am new to sql database programming. developing an application using C# and sql server 2005. i am having problems with date insertion to database. I use datatimepicker control to get date input. here is my code. in table i use datetime column type.

strSQL = "Insert Into TB1 (PPT_No,Reference_No,Application_Date,Receipt_No,Citizenship,Purpose_Visit,Entry_Type,Visa_Category,Airline,Vessel_No,Date_Arrival,
Date_Departs,Collected_Date,Remarks) Values('" +txtPPT_No.Text+ "'," +application_Date.Value+ ",'" +txtRecieptNo.Text+ "','" +cmbcitizenship.Text+ "','"
+txtpurpose.Text+ "','" +cmbentry.Text+ "','" +cmbcategory.Text+ "','" +cmbAirLine.Text+ "','" +txtvesel.Text+
"'," +arrivalDate.Value+ ",'" +departsDate.Value+ ",'" +txtrefference_No.Text+ "'," +collected_Date.Value+ ",'" +txtremarks.Text+ "'";

all date fields i used datetimepicker control. where i went wrong?.

Error : "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

View 4 Replies View Related

Analysis :: Change Dimension Storage Type As Real-time Rolap But Error Occurs?

Jul 7, 2015

I Create a measure group and two dimensions using  [AdventureWorksDW2012], I try to change one dimension's storage mode with setting property proactive caching as Real-Time ROlap. There is no any warning message when deploying and processing, but error occurs when I query in sql server analysis services, see below for the error messages and the screen capture.

Error occurred retrieving child nodes: the current operation was cancelled because another operation in the transaction failed.

View 2 Replies View Related

How Shoud I Assign Database Field To Get Date And Time Automatically

Feb 11, 2006

Hi
I would like to get more information about using detail view together with auto date/time.
I am designing user input form as follow.
tid      : uid     : tool    : priority: reticle: status: remarks: request time :   <- to autogenetrate current timeInsert Cancel
How to use date/time function inside detailed view, insert template.
 
Thanks.
 

View 2 Replies View Related

Convert Date Time(string Format) To Database Timestamp

Apr 3, 2008

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.

Am I on the right track on how to do this?

View 16 Replies View Related

DB Engine :: Check Last Database Index Reorg Date And Time?

May 4, 2015

Are there anyway I can check my last database reorg date and time using Tsql ?

View 5 Replies View Related

SQL 2012 :: Distinct Storage Tier Of Remote BLOB Storage (RBS)

Oct 27, 2014

How to implement distinct storage tiers on SQL Remote BLOB Storage (RBS)?

I want to use this SQL Feature to move files(images, videos, pdf files) from a database to a distinct database dedicated to RBS. Then I want to have several storage tiers, where objects will be saved and moved according access frequency. Old data will be arquived in cheap storage, but it must be always accessible if needed.

Description:
- 1st and main tier: new and frequently accessed objects stored in high performance storage;
- 2nd tier: automatically move older or less accessed objects to an inexpensive and different storage tier;
- in all cases, all objects must be accessible to all users, but accessing to archived objects(2nd tier) will be much slower;

View 0 Replies View Related

Splitting SQL Server Date/Time Column Into Access Date Column And Access Time Column

Jan 24, 2008

I have an SSIS package that moves data from SQL Server to an legacy Access database. In SQL Server, there is a date/time column that I need to split into a separate date column and time column in the access database. Initially I just created a derrived column for the time and set the expression equal to the source date/time column from SQL Server. Unfortunately, that just makes the date column and time column the same having the full date/time.

What expression can I use during a derrived column transformation to assign just the date to a derrived column and just the time to another derrived column?

Thanks,

Steve

View 3 Replies View Related

Date Time In Sql Server 2005

Dec 3, 2007

hi all,
in my sql server 2005 , i 've a table gg containing a column 'date'.its data type is datetime ,null
now i want to insert only the date to this field from vb.net page. i dont want "time" to insert in this page. one more thing ,i know varchar will work for what i need but i want to use date time. If anyone who knows how this is possible pls do send me the code.
 thanks swapna

View 10 Replies View Related

Date/time Problem In SQL Server 7.0

Jun 2, 1999

Hi folks,
I posted the following question on comp.databases.ms-sqlserver,
bu, to my surprise got no responses. So I wondered if you good
people might be able to help us out...
==================================================
Our application communicates with SQLServer 7 through ODBC. In
order to write date/time fields into the database, it uses either the dt
conversion function, or more usually the ts conversion, on a string of
the format 'yyyy-mm-dd hh:mm:ss.xxxxxx'. With almost every every
other database engine (I think Informix is the only exception), this is
accepted and converted into a date format that the back end can store.

With SQLServer 7, any inserts containing dates are dropped because the
timestamp conversion isn't working. If I take a copy of the select statement
into the query analyser, it reports an error unless I change the timestamp
string format from ts 'yyyy-mm-dd hh:mm:ss.xxxxxx' to ts 'yyyy-mm-dd
hh:mm:ss.xxx', ie from microsecond to millisecond resolution.

Version 6.5 didn't have this problem, and as I mentioned, nor does any other
database engine that our application talks to.
================================================== ===

Anyone any ideas???

Cheers,
Geoff.

View 3 Replies View Related

SQL Server Date/Time Question

Oct 22, 2004

I have been searching the net to see how to do this. I'm a noobie to DB's and I may have missed it. OK I have a Customer table and what I want to do is have a column with the date and time that the customer was added to the database ( i.e. Customer Since ) also last time that record was edited. Possible??

Thanks in advanced
Brad Nichols

View 3 Replies View Related

SQL Server 2000 Date Time

Mar 12, 2008

Is there a better way of doing this?


DECLARE @PriorDayDate as varchar(10)
DECLARE @CurrentDayDate as varchar(10)
DECLARE @StartHourTime as varchar(10)
DECLARE @EndHourTime as varchar(10)
DECLARE @PriorDayDateANDStartHourTime as varchar(20)
DECLARE @PriorDayDateANDEndHourTime as varchar(20)
DECLARE @CurrentDayDateANDStartHourTime as varchar(20)
DECLARE @CurrentDayDateANDEndHourTime as varchar(20)

SELECT @PriorDayDate = convert(varchar,(GETDATE()-1),126)
SELECT @CurrentDayDate = convert(varchar,(GETDATE()),126)
SELECT @StartHourTime = convert(varchar,(dateadd(hh, -1, getdate())),108)
SELECT @EndHourTime = convert(varchar,getdate(),108)
SELECT @StartHourTime = left(@StartHourTime, 2) + ':00:0000'
SELECT @EndHourTime = left(@EndHourTime, 2) + ':00:0000'
SELECT @PriorDayDateANDStartHourTime = @PriorDayDate + ' ' + @StartHourTime
SELECT @PriorDayDateANDEndHourTime = @PriorDayDate + ' ' + @EndHourTime
SELECT @CurrentDayDateANDStartHourTime = @CurrentDayDate + ' ' + @StartHourTime
SELECT @CurrentDayDateANDEndHourTime = @CurrentDayDate + ' ' + @EndHourTime

--select @PriorDayDate
--select @CurrentDayDate
--select @StartHourTime
--select @EndHourTime
--select @PriorDayDateANDStartHourTime
--select @PriorDayDateANDEndHourTime
select cast(@PriorDayDateANDStartHourTime as datetime) as 'PD Start Time'
select cast(@PriorDayDateANDEndHourTime as datetime) as 'PD End Time'
select cast(@CurrentDayDateANDStartHourTime as datetime) as 'CD Start Time'
select cast(@CurrentDayDateANDEndHourTime as datetime) as 'CD End Time'

View 14 Replies View Related

The Database File May Be Corrupted. Run The Repair Utility To Check The Database File. [ Database Name = SDMMC Storage Cardwinp

Oct 9, 2007

yes,I have an error, like 'The database file may be corrupted. Run the repair utility to check the database file. [ Database name = SDMMC Storage Cardwinpos_2005WINPOS2005.sdf ]' .I develope a program for Pocket Pcs and this program's database sometimes corrupt.what can i do?please help me

View 4 Replies View Related

Integration Services :: Exclude Time In Date Time Variable In SSIS For Loop?

Oct 22, 2015

I am trying to load previous days data at 3 am via a SSIS job.

The Date variable is initiated as DATEADD("dd",-1, GETDATE()) in the for loop.

Now, as this job runs at 3 am, and I set the variable as GETDATE() - 1, it excluded the data from 12 am to 3 am in the resultset as Date is set as YYYY-MM-DD 03:00:00:000 I need this to be set as YYYY-MM-DD 00:00:00:000

How can i do this? 

View 2 Replies View Related

Calculating Time Between Two Date In Sql Server 2005

Mar 17, 2008

Calculating time between two date In Sql Server 2005help me .. 

View 3 Replies View Related

SQL Server 2008 :: How To Calculate Date Time

Apr 9, 2015

My data is looks like this,

Date---------------------------------------A
2015-03-01 13:38:07.343----------------1
2015-03-01 14:04:04.460----------------1
2015-03-02 19:33:55.117----------------3
2015-03-02 19:33:55.117----------------4
2015-03-02 19:39:26.580----------------1

I want data looks like this

Date-------------------------------------------A
Day 1------------------------------------------2
Day 2------------------------------------------8

View 7 Replies View Related

SQL Server 2008 :: Getting UTC Date And Fixed Time

May 27, 2015

I need to change one of the column to run utctime 2am. Whenever I declared and set the time, it has to run and set up to the UTC 2 am time.

How to declare the variable like that?

If I run that now, it has to set up next utc 2 am time, If I run after 2 hrs also or tomorrow whenever, it has to set the next utc 2am time

View 1 Replies View Related

SQL Server 2012 :: String To Date Without Time

Sep 15, 2015

I have string as '1-12-2012', i wanted to convert it into date as format '2012-12-01'. I used the function as cast('1-12-2012' as Date) it's working but for a set of values where Null occurs it gives error as conversion failed when casting date and/or time from character string.

View 5 Replies View Related

SQL Server 2008 :: How To Add Time From One Field To Date From Another

Nov 2, 2015

If I have a datetime field, RequestDate, and a time field, DecisionTime, how do I add just the date portion of RequestDate to DecisionTime?

View 6 Replies View Related

New Database: Best Practice

Jan 24, 2007

Good Morning,
I work for a company that has sees alot of people come and go. The one thing I have noticed is that people use their admin accounts to log into SQL and create sp, views and databases.When the user leaves I am stuck with all these objects that are owned by somone no longer working for the company.
So my question to you guys is: What is the best practice to use in creating new objects?
Thanks for your guru-ness!

View 3 Replies View Related

Sql Server 2005 Add Current Time To The Passed Date

Jun 2, 2008

 Greetings,I have an e-timesheet application.i made a function that takes the startdate of the week:public SqlDataReader GetProjectsActive(DateTime SheetDate)         {            SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);            SqlCommand myCommand = new SqlCommand("GetProjectsActive", myConnection);            myCommand.CommandType = CommandType.StoredProcedure;            SqlParameter parameterSheetDate = new SqlParameter("@SheetDate", SqlDbType.DateTime);            parameterSheetDate.Value = SheetDate;            myCommand.Parameters.Add(parameterSheetDate);            myConnection.Open();            SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);            return dr;        } i run the application and i pass the value 6/1/2008 (date without time) to the GetProjectsActive but what i notice that the storedprocedure adds the current time to the passsed date when it has been executed so some projects will not  appear since the startdate and enddate of the project are only dates so i try this solution: parameterSheetDate.Value = SheetDate.Date;and it works finebut my question why the current time has been added to the storedprocedure automatically although i pass only the date 6/1/2008 date????your help is highly appreciated.Best regards. 

View 6 Replies View Related

Time Delay In SQL Server 2000 For Date Variable

Nov 6, 2002

Hello I have and tested in 2 way using variable and constant.
Query 1: This query I am using vaiable "@last" for the date value.
this takes to run for 2 minute .

Query 2: Here I am using value '11/05/2002' instead of varialbe and it is running within a second.

Why these much difference to run this same query?.
Can anybody give correct reason or solution for this.
Thanks,
Ravi

query 1:
DECLARE @last smalldatetime
SET @last ='11/05/2002'

select distinct(o.account_num),a.enterprise_num,a.site_nu m
from oesd.dbo.order_header o WITH(NOLOCK)
INNER JOIN oesd.dbo.account a WITH(NOLOCK)
ON a.account_num = o.account_num
and o.added_date > @last
UNION
select distinct(o.account_num),a.enterprise_num,a.site_nu m
from oesd.dbo.order_header o WITH(NOLOCK)
INNER JOIN oesd.dbo.account a WITH(NOLOCK)
ON a.account_num = o.account_num
INNER JOIN Leap.dbo.ENTERPRISE_STATE es WITH(NOLOCK)
ON (a.enterprise_num = es.ENTERPRISE_NUM
AND o.last_updated_date > @last)


Query 2:

select distinct(o.account_num),a.enterprise_num,a.site_nu m
from oesd.dbo.order_header o WITH(NOLOCK)
INNER JOIN oesd.dbo.account a WITH(NOLOCK)
ON a.account_num = o.account_num
and o.added_date > '11/05/2002'
UNION
select distinct(o.account_num),a.enterprise_num,a.site_nu m
from oesd.dbo.order_header o WITH(NOLOCK)
INNER JOIN oesd.dbo.account a WITH(NOLOCK)
ON a.account_num = o.account_num
INNER JOIN Leap.dbo.ENTERPRISE_STATE es WITH(NOLOCK)
ON (a.enterprise_num = es.ENTERPRISE_NUM
AND o.last_updated_date > '11/05/2002' )

View 3 Replies View Related

DB2 Date && Time Datatype Migration To SQL Server Datetime

Feb 15, 2006

Hi,

We are migrating our database from DB2 8 to SQL Server 2005. We have date and time saperate columns in DB2. For example, Date_of_birth, Store_sun_open_time, Store_sun_close_time etc. For date we are using datetime. For time what datatype should we use in SQL Server?

Thanks

Prashant

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved