Questions tagged [getdate]

getdate is a T-SQL function available to retrieve the current system date and time.

getdate() is a function that returns the current system date and time in a datetime format in RDBMSs that use T-SQL. It is available for use in MS SQL Server, SAP/Sybase Adaptive Server Anywhere, SAP/Sybase SQL Anywhere and SAP/Sybase IQ.

412 questions
16
votes
2 answers

How do I add 1 hour to datetime SQL column data?

I used this part of a query to create a table column for the date and time a row is added: order_date datetime NOT NULL DEFAULT GETDATE() and whenever a new row is created, the data for order_date is set to something like this: Apr 8 2014 9:52AM For…
Kelsey
  • 913
  • 3
  • 19
  • 41
16
votes
6 answers

Getdate() function to get date for my timezone

I would love to insert a default value into a column with data type datetime2(7). However, because my website is hosted on a server in a different timezone, the getdate function doesn't work properly. I wonder if there is a solution to this. I have…
loveprogramming
  • 538
  • 2
  • 5
  • 22
12
votes
5 answers

Changing the output of Getdate

Is it possible to deceive SQL Server to return a different date on GetDate() without actually changing the machine date? This would be great, since we have a database with old data and I'm trying to test some queries that use getdate(). I can change…
pauloya
  • 2,535
  • 3
  • 30
  • 50
11
votes
4 answers

SELECT CONVERT(VARCHAR(10), GETDATE(), 110) what is the meaning of 110 here?

When we convert or cast date in sql, see below sql code SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] it works fine, I just want to know the meaning of 110 in above code. what it does actually, sometimes we use 102, 112 etc. what is…
Gaurav
  • 557
  • 4
  • 11
  • 28
11
votes
3 answers

Use of get-date in powershell to create a log string

I'm using these lines in a script to write some information that I'll finally put in a log file. $log = "some text: " $log += Get-Date $log += "; some text" This way I'll get my data correctly, so my output will be some text: 02/13/2013 09:31:55;…
Naigel
  • 9,086
  • 16
  • 65
  • 106
10
votes
2 answers

Convert getdate() to int

When I run the following query: select convert(int, getdate()) I get the result: ----------- 41238 (1 row(s) affected) Does anyone knows what does this mean?
Danilo Lima
  • 299
  • 1
  • 4
  • 13
10
votes
3 answers

Get date using javascript in this format [MM/DD/YY]

how can I get the date in this format [mm/dd/yy] using javascript. I am struggling to get the 'year' to a 2 digit figure as opposed to the full 4 digits. Thanks!
user1779796
  • 479
  • 2
  • 5
  • 11
8
votes
4 answers

How to concatenate a string and GETDATE() in MSSQL

I need to insert a string (a comment) which should include a date. What I need is basically the following simple operation: INSERT INTO [Table_1] ([textColumn]) VALUES ('Date: ' + GETDATE()) GO This however, returns the…
Kjartan
  • 18,591
  • 15
  • 71
  • 96
8
votes
2 answers

Ordering WP Posts by Custom Meta Key

I created a WordPress custom post type to be able to create events, select the event's date, and display the date on the frontend. I added a new meta_key in the postmeta of WP's database to store the event's date in a UNIX timestamp. I've had no…
cqde
  • 695
  • 5
  • 13
  • 22
7
votes
5 answers

Simulate current date on a SQL Server instance?

Is it possible to change the datetime for a particular database on SQL Server? Is it tied to the operating system's date/time? We wish to simulate a future datetime for testing purposes i.e. so the GETDATE() returns a date in the future. It's got to…
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
7
votes
4 answers

SQL Select Records based on current date minus two days

I have an orders table which contains an order ID, order date and order description. I want to run a select query which captures all orders that have been created in the last two days. so the current date minus two days. from the 14th December, I…
Emma
  • 103
  • 1
  • 1
  • 6
7
votes
2 answers

Why does using left() on getdate() change it to a different data type?

Running two simple select statements: SELECT GETDATE() SELECT LEFT(GETDATE(), 10) Returns: 2015-10-30 14:19:56.697 Oct 30 201 I was expecting LEFT() to give me 2015-10-30, but instead it does not. Does anyone know why? Is it to do with the…
S.Beeley
  • 75
  • 1
  • 6
6
votes
5 answers

Evaluating GETDATE twice in a statement - will it always evaluate to be the same?

suppose isnull(some_column, getdate()) >= getdate() where logic is if some_column is null this expression should always be true. However will this always be so (since between two evaluations of getdate() some time has passed and they won't be…
ren
  • 3,843
  • 9
  • 50
  • 95
5
votes
1 answer

strptime in c with timezone offsets

I'm having trouble finding a way to parse the timezone out of strings like the following: "Thu, 1 Sep 2011 09:06:03 -0400 (EDT)" What I need to do in the larger scheme of my program is take in a char* and convert it to a time_t. The following is a…
VMills
  • 183
  • 3
  • 4
  • 12
5
votes
1 answer

php getdate() vs date()

Theoretical question. Imagine the situation. I need to get today date and time (not now, but today - the start of the day). I can do it with either this code: $now = time(); $today = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m", $now), date("d",…
kpower
  • 3,871
  • 4
  • 42
  • 62
1
2
3
27 28