Let's say I have a table called adverts with the following fields: advert_id, name,date_created description, duration, status, user_id, cat_id.
Let's say a user puts a duration of 1 week in the duration field and its status is set to active. After a week has passed, the status is set to inactive in the table.
Can anyone tell me if it's possible to do this with asp.net 4.0 code using visual basic in visual studio 2010 with web forms?
I don't see a reason to update a status at all. Instead of (or in addition to) duration, store the datetime the status is to be set to active (current datetime plus duration). The application can then consider values less than the current datetime as active without having to actually update the row.
If desired, you can still derive the active status as a column the query or as a derived column in the table. For example:
SELECT CASE WHEN active_date <= GETDATE() THEN 'Y' ELSE 'N' END AS active
FROM dbo.adverts;
Related
In Apex app I've a region called Person on a page. Inside a region there is a masked date picker. I have a task to validate the date of birth. So, the date of birth could not be less 1900 year. In "Conditions" section i'd been trying to write an pl/sql expression:
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01.01.1900', 'MM-DD-YYYY')
but it doesn't work. What am I doing wrong?
You put it to wrong place - "Condition" is used to decide whether an item will (or will not) be rendered on the screen.
Validation should be put into ... well, validation (obviously).
right-click the P1002_CONTR_BIRTH_DATE date picker item
choose "Create Validation"
set its type to "PL/SQL function (returning error text)
use such a code (presuming that you set the date picker format mask to MM-DD-YYYY):
if to_date(:P1002_CONTR_BIRTH_DATE, 'mm-dd-yyyy') < date '1900-01-01' then
return ('Error - can not set it to before 01-01-1900');
end if;
set it to fire when SUBMIT button is pressed
Alternatively (and way simpler) would be to open date picker item's property palette, navigate to its "Minimum date" property and put (for example) -120y in there which will allow dates that are higher than sysdate - 120 years (today, Apex would raise the
Birth date is less than specified minimum date 04-15-1898'
which isn't exactly "1900", but - you can easily calculate it, right? Also, -120y is somewhat more flexible than fixed year 1900.
Now you have two options, pick the one that suits you best.
TO_DATE() method is to convert a string to date, the string format should be the same as format_mask.
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01-01-1900', 'MM-DD-YYYY')
or
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01.01.1900', 'MM.DD.YYYY')
and also make sure :P1002_CONTR_BIRTH_DATE is also the same as format.
For detail
I created a database to keep track of customer service related follow-ups in a call centre environment.
My table has, among the others, a Date created field, a Due date field and a Status field (Open, Due or Overdue).
I would like the value indicated in the Status field to update automatically as time elapses.
Can this be achieved and how?
This is absolutely possible. Why not? I would suggest you do the following:
(1) add another status to the status field called 'closed'
(2) determine from a logorithmic perspective what 'Due' means (e.g. if the current date falls within 5 days of your due date
(3) Write a query which updates your status either 'due' or 'overdue' depending on what the current date is
UPDATE tblDue SET tblDue.Status = "Due"
WHERE (((tblDue.DueDate)=Now()));
UPDATE tblDue SET tblDue.Status = "Overdue"
WHERE (((tblDue.DueDate)>Now()));
I'm trying to work with the ASP calendar control and (for starters) highlight the specific days on the calendar that matches DueDate in the 'task' table. I know how to highlight a cell using the DayRender event, but how do I do this in accordance to the database table?
Would then also like to be able to click on the highlighted cell and see details of the task associated to that date in some sort of box next to the calendar.
Any pointers on how I can solve this?
Pseudo-code:
Determine your desired date range (probably a certain month)
Read all the tasks that have due dates within that date range (probably need Name and DueDate at least)
In your DayRender handler you check if current day's date exists in the loaded tasks's due dates, if it does, highlight it with the color of your choice
In you SelectionChanged handler you obtain the selected day's date, and look through the loaded list of tasks for any tasks that have that date as their due date, and populate whatever box with those tasks.
we have a bio metric software for attendance, you press finger over sensor and it puts you IN/OUT time in SQL database, it's desktop app but boss asked me to make same but Web Application in asp.net MVC, now we have 2 tables
tblEmployee
SerialId
EmpId
EmpName
DepId
tblAttendance
AtdId
EmpId (FK)
Time(IN/OUT)
Date
now problem is that When i come into office then it put new record in attendance table and when i leave office then it again put whole record for OUT time in attendance table, it's using same field TIME for IN and OUT both. So thinking to solve this issue like Keeping single record for single day and only changing IN/OUT time ?
This look like normal behavior to me, but still if you want to achive what you have asked, you could change the table definition like this -
tblAttendance
AtdId
EmpId (FK)
Date --Just the date for every day
Time_IN
Time_OUT
Now you need to figure out which swipe it is - IN or OUT and update the particular value. For every IN there would be a new row - which you can control for a particular DATE - as in one row per DATE - Composite Primary Key - AtdId, EmpId (FK), Date
Note - Over the time the above approach will slow down the punch IN/punch OUT process. It'll take comparatively longer to register the swipes. Your current DB structure is more apt for long term usage. If you want to display the data in any particular format, you should rather design views as per your requirements.
I'm looking to either show an error message (fail) the report, if the end time filter is selected as being earlier than the start time filter, or disallow a user from selecting an end time that is before the currently selected start time.
Any ideas? I do not want to lose the pop up calendar functionality for the end time filter. I also don't want to set any kind of default value for the end time based on the start time.
I think Error message is your option.
I looked into this earlier, I couldn't find much on it. Can't really restrict what user can pick unless you want to put valid available dates into a dropdown. If you want the datepicker(popup calendar) and you don't want to set a default for end date based on startdate, then just let the user pick, check if #EndDate < #StartDate either in you query or in an expression of the item you choose to display your message to the user.
Hope it helps