473,513 Members | 4,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data casting, casting operations

Does anybody know how could I calculate the new date(adding @c to @b
or subtracting @b to @c), having for example a declaration like this:
DECLARE @a CHAR(12)
DECLARE @b DATETIME
DECLARE @c INT
SET @b='3.04.04';
SET @c=6

and to calculate the number of days between two dates with this kind
of declaration(@a-@b or @b - @a):
DECLARE @a CHAR(12)
DECLARE @b DATETIME
DECLARE @c INT
SET @a='12.2.04';
SET @b='3.04.04';

Thanks in advance.
Jul 23 '05 #1
1 1339
Take a look at the DATEADD and DATEDIFF functions in Books Online.
Don't specify dates in code in the format you have done. Use 'YYYYMMDD'
which will work safely regardless of regional server and connection
settings.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2055
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of data-types of my choosing (eg an array of char, short, or int). The application has to do with generating checksum-type values for files or strings,...
4
3443
by: Jacob Jensen | last post by:
This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A good way to do this is by example. So I will give an example and please tell me what you think: I have a base class A with a virtual destructor,...
3
8623
by: James Foreman | last post by:
I'm using DB2 UDB 8.1.2 on Suse linux. Try this: CREATE TABLE testsums (cost_of_sale decimal(7,2), price decimal(9, 2)); INSERT INTO testsums VALUES (10000, 30000); SELECT cost_of_sale/price AS division1 FROM testsums; SELECT sum(cost_of_sale)/sum(price) AS division2 FROM testsums; The first select gives 0.333333333333333333333333 The...
18
2152
by: Marco | last post by:
I need to get a iterator from any generic collection. public class .... GetIterator(Object collection) { ..... }
23
3477
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than the Inherit statement).
9
2052
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1. Assign to a datarow (dr1) the first record of the MASTER table 2. Assign to another datarow (dr2) the second record of the MASTER table 3. If...
1
2741
by: tony.fountaine | last post by:
I am working on a project to read a Bosch Measurement Data File (MDF). The file contains a number of blocks that can be read from the file using a baisc structure. For example the ID BLOCK is as follows, (Data Type) (Number of Elements) (Description) CHAR 8 File identifier, CHAR 8 Format identifier, CHAR 8 Program identifier,
5
1292
by: Paulustrious | last post by:
Is it possible to force a cast to an inherited class? class Program { static void Main(string args) { Father Dad = new Father( ); Son boy = (Son) Dad; // <<== fails at run time with invalid cast }
12
13622
by: 6tc1 | last post by:
Hi all, I just discovered a rounding error that occurs in C#. I'm sure this is an old issue, but it is new to me and resulted in a fair amount of time trying to track down the issue. Basically put the following code into your C# app: float testFloat2 = (int) (4.2f * (float)100); Console.Out.WriteLine("1: "+testFloat2); and the result...
17
1324
by: Tem | last post by:
I have classes A,B,C,D,E,F that implement InterfaceBase. Whats the best way to down cast obj to the correct type? Is there a more elegant way to do this than? Public Void DoSomething(InterfaceBase obj) { if(obj is A) ((A)obj).MethodThatOnlyACanDo();
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.