473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

storing monthyear in the same field

66
how to store the month and year in the same field in the database using a query....i have a query which stores current month and year in the different fields.... but i want to store in the form october2007 or 10/2007

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2.  
  3. Dim m As String
  4. Dim y As String
  5. Dim d As Date
  6.  
  7. d = Now()
  8. m = MonthName(Month(Now))
  9. y = Year(Now)
  10.  
  11. With AConn
  12.   .ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=E:\Graph\Graph\xpence.mdb"
  13.   .Open
  14. End With
  15. sSQL = "INSERT INTO Table1(TodayDate,MonthName,YearValues,Amount,Description) " & _
  16. " Values (# " & Format(d, "dd/mm/yyyy") & " #,' " & m & " ',' " & y & " ', ' " & Text3.Text & " ', ' " & Text2.Text & " ') "
  17.  
  18. AConn.BeginTrans
  19. AConn.Execute sSQL
  20. AConn.CommitTrans
  21. AConn.Close
  22.  
  23. End Sub
  24.  
this is the query ...what changes should made to obtain monthyear form......

using vb6.0 and backend is access
Oct 17 '07 #1
5 1146
debasisdas
8,127 Expert 4TB
Just concatenate M and Y and store into a single character field.

For that you need to change your table also.
Oct 17 '07 #2
rekhasc
66
Just concatenate M and Y and store into a single character field.

For that you need to change your table also.
I am not getting ... how to concatenate m & y
Oct 17 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

This query should work for Access:

"Select Format(DateField,'MMM-YYYY') As MonthYear, Sum(Amt) From
MyTable Group By Format(DateField,'MMM-YYYY') "

Regards
Veena
Oct 17 '07 #4
You have to just concatenate the month and year as m & "\" & y. But your database should be restructured to store the value.
Oct 17 '07 #5
debasisdas
8,127 Expert 4TB
I am not getting ... how to concatenate m & y
Expand|Select|Wrap|Line Numbers
  1. Dim m As String
  2. Dim y As String
  3. Dim d As Date
  4. Dim my As String
  5.  
  6. d = Now()
  7. m = MonthName(Month(Now))
  8. y = Year(Now)
  9.  
  10. my = m & y
Oct 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Eben Goodman | last post by:
I am storing book isbn numbers in a table. isbn numbers are 10 digit numbers and many start with 0. The data type of the field I am storing this info in is a bigint(16) unsigned. It appears that...
7
by: C G | last post by:
Dear All, What's the best way to store jpgs in postgresql to use in a web page? I tried to use large objects, but how would you extract them from a table to be viewed in a web-page without...
8
by: TORQUE | last post by:
Hi, I am having some trouble with recording a field on a form into my Table after formatting it to calculate several fields on the form. If i just put the amount in the field and have it linked...
14
by: John Welch | last post by:
Hi all. I'm creating a FE/BE database that will be used by about 6 users. As usual, I have several fields, such as "OrganizationTypeID" that will get values (via combo boxes in forms) from separate...
6
by: (PeteCresswell) | last post by:
User wants to go this route instead of storing pointers in the DB and the documents outside. Only time I tried it was with only MS Word docs - and that was a loooong time ago - and it seemed to...
7
by: fauxanadu | last post by:
Is it possible to store dates before 01/01/0100 A.D. (such as for as database storing world events would require) using MS Access? Verbose Explination I need to be able to store dates before...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
5
by: jalley06 | last post by:
Hi all, I have a form with a field called ReportID in aspx on our local Intranet. Everytime this report is loaded into a browser, I need the ReportID field to be incremented by one. I got this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.